Created
May 9, 2011 12:05
-
-
Save pklaus/962408 to your computer and use it in GitHub Desktop.
tunnelbroker.net : tunnel setup on Linux using "ip" from the iproute suite (iproute2)
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/bash | |
# IPv6 Tunnel setup of an tunnelbroker.net tunnel on Linux using the configuration file `/etc/network/interfaces` | |
# | |
# Run like this: | |
# ./tunnelbroker-net.linux.etc-network-interfaces.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/> | |
TUNNELNAME="he-ipv6" | |
SERVERIPV4ADDR="216.66.80.30" # Server IPv4 address as listed on tunnelbroker.net | |
CLIENTIPV6ADDR="2001:470:1f0a:1abc::2" # Client IPv6 address as listed on tunnelbroker.net | |
ROUTED64="2001:470:1f0b:1abc" # Routed /64 as listed on tunnelbroker.net (without the trailing ::/64) | |
interfaces="/etc/network/interfaces"; | |
grep $TUNNELNAME $interfaces > /dev/null | |
if [ $? = 0 ]; then echo "You already have an entry for the tunnel $TUNNELNAME in your $interfaces file."; exit 1; fi | |
cat << EOF | sudo tee -a $interfaces > /dev/null | |
# IPv6 via HE tunnel... | |
auto $TUNNELNAME | |
iface $TUNNELNAME inet6 v4tunnel | |
address $CLIENTIPV6ADDR | |
endpoint $SERVERIPV4ADDR | |
netmask 64 | |
# ttl 64 | |
#up ip -6 route add default dev $TUNNELNAME | |
up ip -6 route add 2000::/3 dev $TUNNELNAME | |
### $ROUTED64::1:1 is the first IPv6 address on that interface | |
up ip -6 addr add $ROUTED64::1:1/128 dev $TUNNELNAME | |
### $ROUTED64::2:1 is the second (if desired), etc. | |
up ip -6 addr add $ROUTED64::2:1/128 dev $TUNNELNAME | |
down ip -6 route flush dev $TUNNELNAME | |
EOF |
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/bash | |
# IPv6 Tunnel setup of an tunnelbroker.net tunnel on Linux using the `ip` tool | |
# | |
# 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 | |
LOCALIPV4="14.21.215.11" | |
HEIPV4SERVER="216.66.80.30" | |
HEIPV6CLIENT="2001:470:1f0a:1abc::2/64" | |
TUNNELNAME="he-ipv6" | |
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 | |
sudo modprobe ipv6 | |
# 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 | |
# 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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello Phillip, could you help me with Tunelbroker?
I found your configuration script on github, but the site that had the walkthrough was taken down.