Skip to content

Instantly share code, notes, and snippets.

@VictorLowther
Created June 21, 2012 23:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save VictorLowther/2969270 to your computer and use it in GitHub Desktop.
Save VictorLowther/2969270 to your computer and use it in GitHub Desktop.
AT&T 6rd script for DD-WRT
#!/bin/sh
# This adds the appropriate 6rd tunnel for AT&T DSL users with a DD-WRT based router.
# Place it in /jffs/etc/config/att-6rd.wanup, and then ln -s /jffs/etc/config/att-6rd.ipup to it.
# The AT&T customer 6rd gateway.
# This is an anycast address that picks the closest one to you on the AT&T network.
REMOTE=12.83.49.81
# Your local IP address.
LOCAL="$(ip -o -4 addr show dev ppp0 |awk '{print $4}')"
# Your local IP address as an AT&T specific 6rd prefix.
V6PREFIX="$(printf '%02X%02X%02X%02X' $(echo $LOCAL | tr '.' ' ') | awk '{print "2602:30" substr($1,1,1) ":" substr($1,2,4) ":" substr($1,6) "0"}')"
# The local address that will wind up assigned to your bridge
V6LOCAL=$V6PREFIX::1/60
# The remote address bound to the sit tunnel to the 6rd gateway
V6REMOTE=$V6PREFIX::2/28
# The name of the tunnel
TUNNEL=att-6rd
# The MTU of the tunnel. It is the PPP MTU - 20 bytes.
MTU=1472
# Make sure we have needed kernel modules
insmod ipv6
insmod sit
# Clean up any leftovers. This ensures we start with a fresh tunnel whenever the PPP link bounces.
killall radvd
ip -6 addr flush dev br0 scope global
ip -6 addr flush dev $TUNNEL scope global
ip -6 route flush dev br0
ip -6 route flush dev $TUNNEL
ip link set $TUNNEL down
ip tunnel del $TUNNEL
# Create our tunnel.
ip tunnel add $TUNNEL mode sit remote $REMOTE local $LOCAL ttl 64
ip link set $TUNNEL up
ip link set mtu $MTU dev $TUNNEL
ip addr add $V6REMOTE dev $TUNNEL
ip addr add $V6LOCAL dev br0
ip route add ::/0 dev $TUNNEL
# Make sure we forward IPv6 packets
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
# Create an RADVD config file and start radvd to let everyone on our local network get an auto-assigned IP6 address.
cat >/tmp/radvd.conf <<EOF
interface br0 {
AdvLinkMTU $MTU;
AdvSendAdvert on;
prefix $V6PREFIX::/64 {
AdvOnLink on;
AdvAutonomous on;
AdvRouterAddr on;
};
};
EOF
radvd -C /tmp/radvd.conf
# Profit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment