Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ##original https://gist.github.com/1016433
- #Had issues with this and many scripts as they all assumed that my primary router had ipv6 support and that I wasn't hiding behind something.
- #This script sets your Linux (I use Ubuntu) box to function as a 6RD routing device.
- #I've left out radvd as I use HE TunnelBroker for my network's addressing.
- #Get Charter's 6rd host
- HOST6RD=$(nslookup 6rd.charter.com | grep "Address"| awk '{ print $2 }'| tail --lines=1);
- #Get our public IP.
- EXTERNIP=$(wget -q4 -O - http://ifconfig.me/ip);
- #Get the interface that is our 'WAN'.
- #Should always return the interface ip that we talk on our local net with.
- #Shouldn't cause issues unless your external interface is public and on the same subnet as HOST6RD.
- WANIP=$(ip route get $HOST6RD | head --lines=1 | awk '{ print $7 }');
- #What our prefix will be based on our external public IP address.
- V6PREFIX=$(printf ' 2602:100:%02x%02x:%02x%02x' $(echo $EXTERNIP | tr . ' '))
- echo "External IP: $EXTERNIP";
- echo "'WAN' IP: $WANIP";
- echo "IPv6 prefix: $V6PREFIX::/32";
- if [ -n "$EXTERNIP" ]
- then
- #Delete previous tunnel
- ip tunnel del tun6rd
- #Recreate tunnel using the 'WAN' ip.
- ip tunnel add tun6rd mode sit ttl 255 remote any local $WANIP
- ip link set tun6rd mtu 1280
- ip link set tun6rd up
- ip addr add $V6PREFIX::1/32 dev tun6rd
- ip -6 route add ::/0 via ::$HOST6RD dev tun6rd
- ##RADVD SETUP
- echo "interface br0 { \
- MinRtrAdvInterval 3; \
- MaxRtrAdvInterval 10; \
- AdvLinkMTU 1480; \
- AdvSendAdvert on; \
- prefix $V6PREFIX::/64 { \
- AdvOnLink on; \
- AdvAutonomous on; \
- AdvValidLifetime 86400; \
- AdvPreferredLifetime 86400; \
- }; \
- RDNSS 2607:f428:1::5353:1 { }; \
- RDNSS 2607:f428:2::5353:1 { }; \
- };" \
- > /tmp/radvd.conf
- radvd -C /tmp/radvd.conf start
- fi
Advertisement
Add Comment
Please, Sign In to add comment