Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # IPv6 Tunnel setup of an tunnelbroker.net tunnel on Linux using the `ip` tool from the iproute suite (iproute2)
- # Website of iproute2: <http://www.linux-foundation.org/en/Net:Iproute2>
- # Package on Ubuntu: <http://packages.ubuntu.com/iproute> and on Arch Linux <http://www.archlinux.org/packages/?&q=iproute2>
- #
- # Run like this:
- # ./tunnelbroker-net.linux.sh
- #
- # 2011 by Philipp Klaus
- # Published on <http://blog.philippklaus.de/2011/05/ipv6-6in4-tunnel-via-hurricane-electric-tunnelbroker-net-tunnel-setup-on-ubuntu-11-04/>
- # Uncomment this line to debug the script:
- #set -x
- # CONFIGURATION BEGINS HERE
- #ALL OF THESE INFORMATION CAN BE OBTAINED FROM http://tunnelbroker.net/tunnel_detail.php?
- LOCALIPV41=`wget -qO- http://v4.ipv6-test.com/api/myip.php` # do not touch this unless you plan to use another site or comment this if you are on static ip
- LOCALIPV4="" # your local IP address ,(i.e behind router/public IP address)
- HEIPV4SERVER="" # tunnel's server IP Address
- HEIPV6CLIENT="" # Client Address generally ends with 2
- TUNNELNAME="he-ipv6" # feel free to name it
- ROUTE64="" # your Route64 ID
- HEUSER='' # hash from the website, "UserID" (under the main page)
- HEPASS='' # hash: echo -n MyPass|md5 (or use an online md5 hash tool)
- HETUNNEL= # from the website, "Global Tunnel ID" - it can be obtained from the URL of your tunnel
- ETH="" # your ethernet/wlan adapter (i.e en0 , en1 , etc)
- IPADR="" # your Routed64 Address + 1 (i.e 2001:45:19:e35::1) just add 1 after the two ::
- # CONFIG ENDS HERE
- echo "Please enter your user account password. It is needed to set up the IPv6 tunnel."
- sudo echo "Gained superuser permissions"
- if [ $? == 1 ]; then echo "Sorry! You need to provide your password in order to set up the tunnel."; exit 1; fi
- # If you have the UFW firewall running on your system, make sure, passing proto 41 is allowed
- # found on <https://bugs.launchpad.net/ufw/+bug/502655/comments/8>
- #sudo ufw allow proto ipv6 from $HEIPV4SERVER
- cat << "EOF"
- Please make sure, that `IPV6=yes` is set in `/etc/default/ufw`. After changing this,
- you have to run `sudo ufw disable && sudo ufw enable` in order to get it to work.
- EOF
- # It pretty much removes any tunnel and recreates them back , this is to avoid some issues and stuff
- sudo ip tunnel del $TUNNELNAME
- sudo ip route delete ::/0 dev $TUNNELNAME
- sudo ip addr del $HEIPV6CLIENT dev $TUNNELNAME
- sudo ip link set $TUNNELNAME down
- sudo ip tunnel del $TUNNELNAME
- #This part "updates" your IP Address , ideal for those who are using dynmanic IP
- #Comment the part below if you are on static IP
- curl -k -s "https://ipv4.tunnelbroker.net/ipv4_end.php?ip=$LOCALIPV41&pass=$HEPASS&apikey=$HEUSER&tid=$HETUNNEL"
- # Now setup the tunnel, start the link, add the IPv6 address to the tunnel and set up routing.
- sudo ip tunnel add $TUNNELNAME mode sit remote $HEIPV4SERVER local $LOCALIPV4 ttl 255
- sudo ip link set $TUNNELNAME up
- sudo ip addr add $HEIPV6CLIENT dev $TUNNELNAME
- sudo ip route add ::/0 dev $TUNNELNAME
- sudo ip -6 addr add $IPADR dev $ETH
- ip -f inet6 addr # ← show the current IPv6 addresses on you machine
- cat << EOF
- You set up the tunnel. To remove the tunnel again, run these commands:
- sudo ip route delete ::/0 dev $TUNNELNAME
- sudo ip addr del $HEIPV6CLIENT dev $TUNNELNAME
- sudo ip link set $TUNNELNAME down
- sudo ip tunnel del $TUNNELNAME
- EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement