[openwrt/nat64] add bgp config generator

This commit is contained in:
Nico Schottelius 2024-07-23 13:38:49 +02:00
parent efb9b1ca0d
commit 34df05c158

View file

@ -9,14 +9,17 @@
# - do not provide IPv4 or IPv6 dhcp/ra on any interface
if [ $# -lt 4 ] ; then
echo $0 "address hostname nat64prefix asn iBGPpeer1 [iBGPpeer2...]"
echo $0 "address hostname nat64prefix nat64route asn routerid iBGPpeer1 [iBGPpeer2...]"
exit 1
fi
address=$1; shift
hostname=$1; shift
nat64=$1; shift
nat64prefix=$1; shift
nat64route=$1; shift
asn=$1; shift
routerid=$1; shift
ibgp_peers="$@"
# Now $@ only contains iBGP peers
@ -36,8 +39,32 @@ uci set system.@system[0].hostname="${hostname}"
# Do something wireless (?)
# disable?
echo "Setting up ibgp for $@ .."
echo "Setting up bird ..."
cat > /etc/bird.conf <<BBB
log syslog all;
router id ${routerid};
protocol static static6 {
ipv6;
route ${nat64prefix} unreachable;
}
BBB
for ibgp_peer in ${ibgp_peers}; do
cat >> /etc/bird.conf <<BBB
protocol bgp {
local as ${asn};
neighbor ${ibgp_peer} as ${asn};
ipv6 {
import none;
export where source ~ [ RTS_STATIC ];
};
}
BBB
uci commit
/etc/init.d/bird restart
EOF