Hurricane Electric's IPv6 Tunnel Broker Forums
June 19, 2013, 06:08:06 am *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to Hurricane Electric's Tunnelbroker.net forums!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: IPv6 on DD-WRT  (Read 3613 times)
docbill
Newbie
*
Posts: 5


View Profile
« on: January 28, 2011, 02:55:52 pm »

After trying every single tip I could find on the net, I finally managed to get IPV6 working.   Unlike other approaches, I decided to do my scripting in such a way I could easily toggle back and forth from the tunnel broker and just IPV6 to IPV4 tunnel.  I did this since it gives me a good way to tell the difference between a tunnel problem, and generic IPV6 intranet problem.

First the main script.  This is a re-factorization of other scripts I've seen on the net.  Install as /jffs/updateipv4.sh:

#!/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=$(ip -4 addr show dev vlan2 | grep 'inet ' | awk '{print $2}' | cut -d/ -f
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.co
        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
            ip tunnel add he-ipv6 mode sit ttl 255 remote $SERVER_IPV4_ADDRESS l
            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 \(..\):\(..\):\(..\):\
            # These commands aren't on HE's website, but they're necessary for t
            ip -6 addr add $(echo "$ROUTED_ADDRESS"|sed "s,::/..,::$BR0_MAC/64,"
            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                                                                              

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/updateipv6.sh 2> /jffs/startup.debug
kill -HUP $(cat /var/run/radvd.pid)
sleep 10
echo "starting radvd" >> /jffs/startup.debug
radvd -C /jffs/radvd.conf start &


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 updateipv6.sh script interactively.   Note: I've designed the updateipv6.sh script 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.   If you want to force it to run anyway (for debugging purposes), the simply remove the /tmp/wanip file first.  e.g.

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


Regards,

Bill
« Last Edit: January 28, 2011, 03:00:53 pm by docbill » Logged
dfcs
Newbie
*
Posts: 2


View Profile
« Reply #1 on: February 01, 2011, 08:18:29 am »

I've done all this by my tunnel to HE keeps dropping with a period of inactivity (under 1 min). If I keep a ICMPv6 ping going to the server it keeps the tunnel open. Any ideas how to fix this?
Logged
nature6pk2
readonly_member
Newbie
*
Posts: 1


View Profile
« Reply #2 on: February 05, 2011, 12:19:05 am »

Hi is there a chance you can post the full updateipv4.sh script?  It's cut off on column 80 and seems to be broken, at least for me.
Logged
gcamp0730
Newbie
*
Posts: 1


View Profile
« Reply #3 on: February 15, 2011, 06:19:50 am »

Here is the full script, not cropped at 80 cols.  Also, based on the commands in the startup script, this should actually be called updateipv6.sh, not updateipv4.sh

Code:
#!/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=$(ip -4 addr show dev vlan2 | grep 'inet ' | awk '{print $2}' | cut -d/ -f1)
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
Logged
torchddv
Newbie
*
Posts: 5


View Profile
« Reply #4 on: April 01, 2011, 07:50:04 pm »

What version and build of DD-WRT are you using? I tried your setup, and it doesn't work for me either. I suspect you may have an older build.

I also noticed you don't seem to have any firewall entries???

EDIT: I should add that I tried it using v24 sp2 NOKAID newd, build 16403.
« Last Edit: April 02, 2011, 05:44:37 pm by torchddv » Logged
k8r2
Newbie
*
Posts: 1


View Profile
« Reply #5 on: April 06, 2011, 05:12:21 am »

I have same problem.
Tunnel works for some minutes and then when idle it stops working.
Using v24 sp2 NOKAID 16403 on WRT54GL

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!