Created
February 1, 2011 18:32
-
-
Save adh/806333 to your computer and use it in GitHub Desktop.
Setup 6to4 and radvd with dynamic IPv4 address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IPv4=`ip a | sed -n '/eth0/,$p' | grep '^[[:space:]]*inet' | head -n 1 | sed -r 's/^[[:space:]]*inet[[:space:]]+([[:digit:].]+).*$/\1/'` | |
prefix=` echo $IPv4 | tr '.' '\n' | sed '1iobase=16'| bc | sed 's/^.$/0\0/'| tr -d '\n' | sed 's/^..../\0:/'` | |
cat >/etc/radvd.conf << EOF | |
interface eth1 | |
{ | |
AdvSendAdvert on; | |
prefix 2002:$prefix:100::/64 | |
{ | |
}; | |
}; | |
interface eth2 | |
{ | |
AdvSendAdvert on; | |
prefix 2002:$prefix:1000::/64 | |
{ | |
}; | |
}; | |
EOF | |
ip tunnel add tun6to4 mode sit remote any local $IPv4 | |
ip link set dev tun6to4 up | |
ip -6 addr add 2002:$prefix::1/16 dev tun6to4 | |
ip -6 route add 2000::/3 via ::192.88.99.1 dev tun6to4 metric 1 | |
ip -6 addr add 2002:$prefix:100::1/64 dev eth1 | |
ip -6 addr add 2002:$prefix:1000::1/64 dev eth2 | |
ip6tables -A INPUT -i tun6to4 -j from-internet | |
sysctl net.ipv6.conf.all.forwarding=1 | |
/etc/init.d/radvd start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment