Created
May 23, 2011 17:51
-
-
Save jbhannah/987146 to your computer and use it in GitHub Desktop.
Hurricane Electric IPv6 Tunnel Broker script for Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Hurricane Electric IPv6 Tunnel Broker script for Ubuntu | |
# /etc/network/if-up.d/he-ipv6.sh | |
# Written by Jesse B. Hannah (http://jbhannah.net) <[email protected]> | |
# Based on instructions provided by Hurricane Electric (http://tunnelbroker.net) | |
### | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in | |
# all copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
# THE SOFTWARE. | |
### | |
# This script does all of the necessary configuration to enable direct IPv6 | |
# connectivity via a Hurricane Electric IPv6 tunnel from http://tunnelbroker.net | |
# on an Ubuntu or other Linux system when radvd is unavailable on the network, | |
# or for setting up radvd on the system. | |
# To use this script, put it in /etc/network/if-up.d and make it executable, | |
# then run it by itself or restart the networking services. | |
# Load the kernel IPv6 module. This isn't necessary on Linode. | |
modprobe ipv6 | |
# The primary internet-facing network interface | |
MY_IF=eth0 | |
# Given under "IPv6 Tunnel Endpoints" on the tunnel details page | |
SERVER_V4=xxx.xxx.xxx.xxx | |
CLIENT_V6=2001:xxx:xxxx:xxx::2/64 | |
# An address from your Routed /64 or /48 prefix for the local interface | |
LOCAL_V6=2001:xxx:xxxx:xxx::1337/64 | |
# If you have a static IP address (such as on Linode), you can comment these out. | |
# Otherwise, set them to your tunnelbroker.net username and password, and your tunnel ID. | |
HE_USER= | |
HE_PASS= | |
HE_TUNNEL= | |
# URL encode your username and password and update the client IPv4 endpoint of your tunnel | |
# Again, if you have a static IP address, you can skip this. | |
HE_USER_ENC=`perl -MURI::Escape -e "print uri_escape('$HE_USER')"` | |
HE_PASS_ENC=`perl -MURI::Escape -e "print uri_escape('$HE_PASS')"` | |
curl -k -s "https://$HE_USER_ENC:[email protected]/ipv4_end.php?tid=$HE_TUNNEL" | |
# Get the local IPv4 address of your primary interface | |
LOCAL_V4=`ifconfig $MY_IF | grep -E 'inet addr:[\.0-9]*' | sed s/addr:// | awk '{ print $2 }'` | |
# Drop any existing tunnel | |
ip tunnel del he-ipv6 | |
ip addr del $LOCAL_V6 dev $MY_IF | |
# Configure the tunnel and local interfaces and routing table | |
ip tunnel add he-ipv6 mode sit remote $SERVER_V4 local $LOCAL_V4 ttl 255 | |
ip link set he-ipv6 up | |
ip addr add $CLIENT_V6 dev he-ipv6 | |
ip addr add $LOCAL_V6 dev $MY_IF | |
ip route add ::/0 dev he-ipv6 | |
# Uncomment or run the following separately to check your address configuration | |
# ip -f inet6 addr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like there's a new format.
Substitute the following for lines 55-62:
LOCAL_V4=
ifconfig $MY_IF | grep -E 'inet addr:[\.0-9]*' | sed s/addr:// | awk '{ print $2 }'
HE_USER_ENC=
perl -MURI::Escape -e "print uri_escape('$HE_USER')"
HE_PASS_ENC=
perl -MURI::Escape -e "print uri_escape('$HE_PASS')"
curl -k -s "https://$HE_USER_ENC:$[email protected]/nic/update?hostname=$HE_TUNNEL&myip=$LOCAL_V4"