ungleich-tools/openwrt/openwrt-add-jool-ipv4island.sh

42 lines
807 B
Bash
Raw Normal View History

#!/bin/sh
2021-11-01 10:12:27 +00:00
if [ $# -ne 2 ]; then
echo "$0 ip-address nat64-prefix"
echo " ip-address: where to find the OpenWRT device"
2021-11-01 10:10:44 +00:00
echo " nat64-prefix: how to reach the ipv4 hosts"
echo ""
echo "Example:"
echo "$0 2a0a:e5c1:301::42 2a0a:e5c1:301:b00::/96"
echo ""
echo "This maps 2a0a:e5c1:301:b00::/96 to the IPv4 addresses on the device 2a0a:e5c1:301::42"
exit 1
fi
my_ip=$1; shift
nat64_prefix=$1; shift
cat <<EOF | ssh -t "root@${my_ip}"
set -x
opkg update
opkg install kmod-jool jool-tools
2021-11-07 15:25:02 +00:00
cat <<EO2 > /etc/rc.local
2021-11-01 10:10:44 +00:00
sysctl -w net.ipv6.conf.all.accept_ra=2
modprobe jool
2021-11-07 15:25:02 +00:00
jool instance add default --netfilter -6 ${nat64_prefix}
EO2
2021-11-01 10:10:44 +00:00
# OpenWRT has 192.168.1. assigned on LAN by default
# Probably not even necessary
# jool -4 -a 192.168.1.1
2021-11-07 15:25:02 +00:00
sh /etc/rc.local
EOF