2024-07-22 10:06:04 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Nico Schottelius, 2024-07-22
|
|
|
|
# This script assumes a clean/newly setup openwrt device
|
|
|
|
#
|
|
|
|
# Assumption:
|
|
|
|
# WAN = IPv4, dhcp provided externally
|
|
|
|
# LAN = IPv6, "clients" that want to reach IPv4 Internet
|
|
|
|
# Consequences
|
|
|
|
# - do not provide IPv4 or IPv6 dhcp/ra on any interface
|
|
|
|
|
2024-07-23 08:27:58 +00:00
|
|
|
if [ $# -lt 4 ] ; then
|
2024-07-23 11:38:49 +00:00
|
|
|
echo $0 "address hostname nat64prefix nat64route asn routerid iBGPpeer1 [iBGPpeer2...]"
|
2024-07-22 10:06:04 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
address=$1; shift
|
|
|
|
hostname=$1; shift
|
2024-07-23 11:38:49 +00:00
|
|
|
nat64prefix=$1; shift
|
|
|
|
nat64route=$1; shift
|
2024-07-23 08:27:58 +00:00
|
|
|
asn=$1; shift
|
2024-07-23 11:38:49 +00:00
|
|
|
routerid=$1; shift
|
|
|
|
ibgp_peers="$@"
|
2024-07-23 08:27:58 +00:00
|
|
|
|
|
|
|
# Now $@ only contains iBGP peers
|
2024-07-22 10:06:04 +00:00
|
|
|
|
|
|
|
cat <<EOF | ssh -t "root@${address}"
|
|
|
|
set -x
|
|
|
|
opkg update
|
2024-07-23 08:27:58 +00:00
|
|
|
|
|
|
|
# add jool + bird2
|
2024-07-23 11:49:44 +00:00
|
|
|
opkg install jool-tools-netfilter bird2 bird2c
|
2024-07-22 10:06:04 +00:00
|
|
|
|
|
|
|
# Do not announce ULA - we have GUA
|
|
|
|
uci delete network.globals.ula_prefix
|
|
|
|
|
|
|
|
# Set hostname
|
|
|
|
uci set system.@system[0].hostname="${hostname}"
|
|
|
|
|
|
|
|
# Do something wireless (?)
|
|
|
|
# disable?
|
|
|
|
|
2024-07-23 11:38:49 +00:00
|
|
|
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};
|
2024-07-23 11:49:44 +00:00
|
|
|
neighbor \${ibgp_peer} as ${asn};
|
2024-07-23 11:38:49 +00:00
|
|
|
|
|
|
|
ipv6 {
|
|
|
|
import none;
|
|
|
|
export where source ~ [ RTS_STATIC ];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
BBB
|
2024-07-23 11:41:54 +00:00
|
|
|
done
|
2024-07-23 08:27:58 +00:00
|
|
|
|
2024-07-23 11:51:05 +00:00
|
|
|
# TODO: configure jool
|
|
|
|
# TODO: start jool
|
|
|
|
# TODO: ensure jool is started at boot
|
|
|
|
# TODO: ensure bird is started at boot
|
|
|
|
|
|
|
|
|
2024-07-22 10:18:48 +00:00
|
|
|
uci commit
|
2024-07-23 11:38:49 +00:00
|
|
|
/etc/init.d/bird restart
|
2024-07-22 10:18:48 +00:00
|
|
|
|
2024-07-22 10:06:04 +00:00
|
|
|
EOF
|