Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrobertson/992225 to your computer and use it in GitHub Desktop.
Save jrobertson/992225 to your computer and use it in GitHub Desktop.
SixXS Static 6in4 IPv6 Tunnel on Ubuntu / Debian defined in `/etc/network/interfaces`
#!/bin/bash
# IPv6 Tunnel setup of an sixxs.net tunnel on Linux using the configuration file `/etc/network/interfaces`
# (needs the `ip` tool from the iproute suite, Ubuntu package: <http://packages.ubuntu.com/iproute>)
#
# Run like this:
# ./setup_etc-network-interfaces_static-ipv6-tunnel-via-sixxs.sh
#
# 2011 by Philipp Klaus
# Published on <http://blog.philippklaus.de/2011/05/sixxs-static-6in4-ipv6-tunnel-on-ubuntu-debian/>
#### You get the following settings on sixxs.net/home → tunnel
SERVERIPV4ADDR="216.66.80.30" # PoP IPv4 Endpoint
SERVERIPV6ADDR="2001:ff00:4d0d:755::1" # PoP IPv6 Endpoint
CLIENTIPV6ADDR="2001:1f0a:407:1abc::2" # Your IPv6 Endpoint
#------------
TUNNELNAME="sixxs"
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
# Please refer to <http://www.sixxs.net/faq/connectivity/?faq=ossetup&os=linuxdebian> for further information
auto $TUNNELNAME
iface $TUNNELNAME inet6 v4tunnel
address $CLIENTIPV6ADDR
netmask 64
endpoint $SERVERIPV4ADDR
ttl 64
## If you configured the *Tunnel MTU* to 1480 on sixxs.net, then use this value below
up ip link set mtu 1280 dev $TUNNELNAME
up ip route add default via $SERVERIPV6ADDR dev $TUNNELNAME
#pre-up modprobe ipv6
#pre-up ip6tables-restore < /etc/network/ip6tables
EOF
grep $TUNNELNAME $interfaces > /dev/null
if [ $? = 0 ]; then echo "Successfully added the tunnel $TUNNELNAME to your $interfaces file."; exit 0; fi
echo "Something went wrong. Sorry."; exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment