Buffalo WZR-HP-G300NH2 Router with DD-WRT and IPv6 from Hurricane Electric

Modified from http://www.dd-wrt.com/wiki/index.php/IPv6_setup_Hurricane_Electric_Tunnel_Broker

Hurricane Electric’s Free Tunnelbroker.net

Registration

1) Sign up for an account with our web based registration at Tunnelbroker.net

2) After creating your account, provide your IPv4 endpoint, and pick the closest tunnel-server to your location:

Asia

  • Hong Kong, HK
  • Singapore, SG
  • Tokyo, JP

Europe

  • Amsterdam, NL
  • Paris, FR
  • Stockholm, SE
  • Zurich, CH

North America

  • Ashburn, VA, US
  • Chicago, IL, US
  • Dallas, TX, US
  • Fremont, CA, US
  • Los Angeles, CA, US
  • Miami, FL, US
  • New York, NY, US
  • Seattle, WA, US
  • Toronto, ON, CA

Features

By default you already get a /64 allocation routed to your side of the tunnel.

If you need more than a single /64, with the click of a button you can allocate a single /48 routed to your side of the tunnel.

A large variety of configuration examples are provided for various platforms covering: Linux, *BSD, Windows as well as router platforms.

Tunnelbroker.net is operated and maintained by a business and not individuals, and provided FREE to anyone interested in learning more about IPv6.

Setup

My fist step was to get jffs2 working on my Buffalo router. After many attempts through the user interface, I found the following commands from a terminal session worked to enable read/write access to jffs2.

nvram set jffs_mounted=1
nvram set enable_jffs2=1
nvram set sys_enable_jffs2=1
nvram set clean_jffs2=1
nvram set sys_clean_jffs2=1
nvram commit
reboot

Now that we have read/write access to the jffs2 file system, since we need a way to recycle the tunnel when the router’s IPV4 address change, it makes sense to put the main logic in a separate script. The following is the /jffs/updateipv4.sh script:

#!/bin/sh -x
#SAMPLE USERID="29812e32f424324324234"
USERID="<insert value here>"
#SAMPLE PASSWORD="CatsAndDogs"
PASSWORD="<insert value here>"
#SAMPLE TUNNEL_ID="96782"
TUNNEL_ID="<insert value here>"
#SAMPLE CLIENT_IPV6_ADDRESS="2001:271:18:2c7::2/64"
CLIENT_IPV6_ADDRESS="<insert value here>"
#SAMPLE SERVER_IPV4_ADDRESS="218.65.27.48"
SERVER_IPV4_ADDRESS="<insert value here>"
echo >> /tmp/wanip
WANIP_OLD=`cat /tmp/wanip`
WANIP=`ifconfig vlan2 | grep 'inet addr:' | awk '{print $2}' | cut -d/ -f1 | awk -F"addr:" '{print $2}'`
if [ -n "$WANIP" ]
then
 if [ "$WANIP" != "$WANIP_OLD" ]
 then
 echo "External IP: $WANIP" 1>&2
 ROUTED_ADDRESS=`sed -n -e 's,^ *prefix *\([^ ]*\) *{,\1,p' /tmp/radvd.conf`
 if [ "$ROUTED_ADDRESS" = "0:0:0:1::/64" ]
 then
 CLIENT_IPV6_ADDRESS=""
 fi
 ip tunnel del tun6to4 2>>/dev/null
 ip tunnel del he-ipv6 2>>/dev/null
 if [ -n "$CLIENT_IPV6_ADDRESS" ]
 then
 echo "Configure he-ipv6 tunnel" 1>&2
 MD5PASSWORD=`echo -n "$PASSWORD"|md5sum|sed -e 's/ *-//g'`
 /usr/bin/wget 'http://ipv4.tunnelbroker.net/ipv4_end.php?ipv4b='AUTO'&pass='$MD5PASSWORD'&user_id='$USERID'&tunnel_id='$TUNNEL_ID' -O - exit'
 ip tunnel add he-ipv6 mode sit ttl 255 remote $SERVER_IPV4_ADDRESS local $WANIP
 ip link set he-ipv6 up
 ip addr add $CLIENT_IPV6_ADDRESS dev he-ipv6
 ip route add ::/0 dev he-ipv6

 BR0_MAC=`ifconfig br0 |sed -n -e 's,.*HWaddr \(..\):\(..\):\(..\):\(..\):\(..\):\(..\).*,\1\2:\3\4:\5\6,p'`
 # These commands aren't on HE's website, but they're necessary for the tunnel to work
 ip -6 addr add $(echo "$ROUTED_ADDRESS"|sed "s,::/..,::$BR0_MAC/64,") dev br0
 ip -6 route add 2000::/3 dev he-ipv6
 else
 echo "Configure tun6to4 tunnel" 1>&2
 V6PREFIX=`printf '2002:%02x%02x:%02x%02x' $(echo $WANIP | tr . ' ')`
 ip tunnel add tun6to4 mode sit ttl 255 remote any local $WANIP 
 ip link set tun6to4 mtu 1480 
 ip link set tun6to4 up 
 ip -6 addr add $V6PREFIX:0::1/16 dev tun6to4 
 ip -6 addr add $V6PREFIX:1::1/64 dev br0 
 ip -6 route add 2000::/3 via ::192.88.99.1 dev tun6to4 
 fi
 echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
 fi
fi

You will likely need to terminal into the router and use vi to create the file. Be sure to run:

chmod ugo+rx /jffs/updateipv4.sh

Next the startup script. Set this in your startup under Administration->Commands->Startup:

#Enable IPV6
insmod /lib/modules/`uname -r`/kernel/net/ipv6/sit.ko
sleep 5
radvd -C /tmp/radvd.conf start
sleep 5
rm -f /tmp/wanip
/jffs/updateipv4.sh 2> /jffs/startup.debug
kill -HUP $(cat /var/run/radvd.pid)
sleep 10
echo "starting radvd" >> /jffs/startup.debug
radvd -C /tmp/radvd.conf start &

Note: The sleep commands are just to give time for the IPV4 network to come-up, and for the updates from the script to finish.

Finally, Radv5 config. Set this under Administration->Management->IPV6 Support->Radvd config:

interface br0 {
MinRtrAdvInterval 3;
MaxRtrAdvInterval 10;
AdvLinkMTU 1480;
AdvSendAdvert on;
prefix <insert value here> {
AdvOnLink on;
AdvAutonomous on;
AdvValidLifetime 86400;
AdvPreferredLifetime 86400;
# Base6to4Interface vlan2;
};
};

The prefix value should be your Route 64 address. e.g. 2001:270:1c:1d8::/64

If instead you wish to use an IPV6 to IPV4 bridge instead use an address of 0:0:0:1::/64 and uncomment the Base6to4Interface line like the following:

interface br0 {
MinRtrAdvInterval 3;
MaxRtrAdvInterval 10;
AdvLinkMTU 1480;
AdvSendAdvert on;
prefix 0:0:0:1::/64 {
AdvOnLink on;
AdvAutonomous on;
AdvValidLifetime 86400;
AdvPreferredLifetime 86400;
Base6to4Interface vlan2;
};
};

Walla. Once everything is saved you are ready to reboot your router. If things don’t work try running the updateipv4.sh script interactively. Note: The updateipv4.sh script has been designed so it can be rerun regularly to pickup a new wan ip address. So if the wanip is the same as the last time it ran, it does nothing. I would recommend putting in a cron job in Administration -> Management -> Additional Cron Jobs to run the script regularily.

* 4 * * * root /jffs/updateipv4.sh

If you want to force it to run from the terminal session anyway (for debugging purposes), then simply remove the /tmp/wanip file first. e.g.

$ rm /tmp/wanip;/jffs/updateipv4.sh

 

Posted in Ramblings.