#!/bin/sh # rc.hurricane - version 0.2 # Hurricane Electric TB - IPv4 endpoint update script # Required packages: curl, gawk, iproute2 # # Usage: ./rc.hurricane [-4] # or [-t] # Arguments: # -4 - updates only IPv4 endpoint # -t - updates only tunnel interfaces # Running without arguments will update both things." # # History: # 0.1 (2008-07-30) - first release # 0.2 (2009-04-19) - removed deprecated sit0 interface # # copyleft (c) 2008-2009 Damian Pasternok # All rights reversed. # ### config NETIF=ppp0 # WAN interface (if empty or incorrect the 'whatismyip' will be used) TUNIF=he-ipv6 # tunnel interface SVIPV4=216.66.80.30 # Server IPv4 address (get this from the tunnel details page) CLIPV6=2001:0470:1234:abc::2/64 # Client IPv6 address (get this from the tunnel details page) USERID=0123456789abcdef0123456789abcdef # UserID (get this from the main page of the tunnelbroker) PASSWD=abcdef0123456789abcdef0123456789 # MD5 Hash of your password (make this with echo -n | openssl md5) TUNID=12345 # Global Tunnel ID (get this from the tunnel details page) # ### code function whatismyip { curl -s "http://whatismyip.com/automation/n09230945.asp" } function usage { echo "Usage: ./rc.hurricane [-4] or [-t] Arguments: -4 - updates only IPv4 endpoint -t - updates only tunnel interface Running without arguments will update both things." } OK="\r\t\t\t\t\t\t[\033[1;32;40m ok \033[0m]" FAIL="\r\t\t\t\t\t\t[\033[1;31;40mfailed\033[0m]" # # get new IPv4 if [ $NETIF ]; then NEWIP=`ip addr show dev $NETIF 2> /dev/null | grep inet | awk '{ print $2 }'` if [ ! $NEWIP ]; then NEWIP=`whatismyip` fi else NEWIP=`whatismyip` fi # # update IPv4 endpoint if [ ! $1 ] || [ $1 = "-4" ] && [ ! $2 ]; then echo -n "Trying to update new IPv4 endpoint..." RES=`curl -Gksd "ipv4b=${NEWIP}&pass=${PASSWD}&user_id=${USERID}&tunnel_id=${TUNID}" "https://ipv4.tunnelbroker.net/ipv4_end.php"` if [ "$RES" = "That IPv4 endpoint is already in use." ]; then echo -e "$FAIL\n$RES" else echo -e "$OK\n$RES" fi if [ $1 ]; then exit fi elif [ $1 != "-t" ]; then usage exit fi # # update tunnel interfaces if [ ! $1 ] || [ $1 = "-t" ] && [ ! $2 ]; then echo -ne "Setting up \033[1;29;40m${TUNIF}\033[0m..." ip tunnel del $TUNIF 2> /dev/null ip tunnel add $TUNIF mode sit remote $SVIPV4 local $NEWIP ttl 255 ip link set $TUNIF up echo -ne "$OK\nAdding IPv6 and route to \033[1;29;40m${TUNIF}\033[0m..." ip addr add $CLIPV6 dev $TUNIF ip route add ::/0 dev $TUNIF echo -e "$OK" exit else usage exit fi