Hurricane Electric's Tunnelbroker endpoint address update script

This script is purely based on common tools and does not require Perl packages.
It is intended to work with all platforms, including lightweight, busybox based, routers (like OpenWrt or dd-wrt).


All parameters can be staticly set into the shell script, so edit it first.
# When empty, IPv4 value is fetched from whatismyip
# IPV4=""

Get first your userid and tunnelid from your tunnel web interface (the numeric value is shown in the configured tunnel detail url, tunnelid variable)

Command line (overrides static parameters) also available:
	updateipv4 [ipv4 [ tunnel_id [ userid password ] ] ]


Download (version 0.50, NON-WORKING!) here:
Download (version 0.51) here: (updated for the new userid parameter)
0.51 version does not handle return codes yet (TODO)

How to integrate

The best way is to create a script that will run standalone.
As DDwrt firmware (and openwrt ?) does not provide nohup command we need this kind of script:
(Please replace adresses with your own one as given on tunnelbroker's website, iproute2 section)
trap 'echo 0' 1
while [ true ]
IPV4=`ifconfig vlan1 | grep "inet addr" | sed -e "s+inet addr:++" -e "s+Bcas.*++" -e "s+ *++"`

if [ "$IPV4" != "$OLDIP" ]
sh /jffs/ $IPV4
insmod ipv6
ip tunnel del he-ipv6
ip tunnel add he-ipv6 mode sit remote 216.66.xx local $IPV4 ttl 255
ip link set he-ipv6 up
ip addr add 2001:470:xxxx::2/64 dev he-ipv6
ip addr add 2001:470:xxxx::3/64 dev br0
ip route add ::/0 dev he-ipv6
ip route del 2001:470:xxxx::/64 dev he-ipv6
ip route add 2001:470:xxxx::/64 dev br0

sleep 60

This script use static adresses (as radvd is broken on ddwrt). We just route packets through our network.
All network hosts should use the gateway on interface br0.