IPv6 tunnel on OpenVZ
Jul 22nd, 2013 by morpheus
You can get IPv6 connectivity using a tunnel, if you don’t have native IPv6 support.
Doing this is pretty straightforward if you have a dedicated server or a KVM VPS.
However, with an OpenVZ VPS, things are a little different.
Here’s how you can get IPv6 working on a OpenVZ VPS with a tunnel – Tutorial for Debian (tested on wheezy).
- Create a tunnel at tunnelbroker.net
Hurricane Electric allows creation of up to 5 free IPv6 tunnels @ tunnelbroker.net. Create one for your VPS. - Enable TUN/TAP on your VPS.
It should normally be possible to do this through your control panel (e.g., SolusVM). If not, a support ticket with your provider should get it done fairly quickly. Be advised that toggling this option forces a reboot. So plan accordingly. - Get tb-tun
tb-tun is a userspace program that utilizes TUN/TAP to build a tunnelbroker tunnel on linux. Since we can't do it any other way on a OpenVZ VPS.apt-get install iproute gcc cd /root wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/tb-tun/tb-tun_r18.tar.gz tar -xf tb-tun_r18.tar.gz gcc tb_userspace.c -l pthread -o tb_userspace chmod 0777 /root/tb_userspace
- Create a new init script
nano /etc/init.d/ipv6tb
and put in the following contents (after replacing the correct IP addresses, of course) Remember, for the tunnel, your VPS IP is the client and the Hurricane Electric IP is the server.#! /bin/sh ### BEGIN INIT INFO # Provides: ipv6 # Required-Start: $local_fs $all # Required-Stop: $local_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the ipv6 tunnel # Description: ipv6 tunnel start-stop-daemon ### END INIT INFO # /etc/init.d/ipv6tb touch /var/lock/ipv6tb case "$1" in start) echo "Starting ipv6tb" setsid /root/tb_userspace tb [Server IPv4 Address] [Client IPv4 Address] sit > /dev/null 2>&1 & sleep 3s #ugly, but doesn't seem to work at startup otherwise ifconfig tb up ifconfig tb inet6 add [Client IPv6 Address from your Routed /64]::XXX/128 #Add as many of these as you need from your routed /64 allocation ifconfig tb mtu 1480 route -A inet6 add ::/0 dev tb route -A inet6 del ::/0 dev venet0 ;; stop) echo "Stopping ipv6tb" ifconfig tb down route -A inet6 del ::/0 dev tb killall tb_userspace ;; *) echo "Usage: /etc/init.d/ipv6tb {start|stop}" exit 1 ;; esac exit 0
- Make it executable, and add it to startup
chmod 0755 /etc/init.d/ipv6tb update-rc.d ipv6tb defaults
- Execute it right away
/etc/init.d/ipv6tb start
OR simply reboot. - Test to confirm that IPv6 connectivity is working
ping6 -c 5 google.com
5 Comments on “IPv6 tunnel on OpenVZ”
Leave a Reply
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
[…] 最后是ipv6,在he.net申请tunnel breaker,因为便宜的VPS动不了内核,于是用TB-TUN弄一个用户态隧道,见这里和这里,还有init.d的自启动脚本。 […]
[…] IPv6 tunnel on OpenVZ […]
One of my server got this error:
# /etc/init.d/ipv6tb start
Starting ipv6tb
No support for INET6 on this system.
socket: Address family not supported by protocol
socket: Address family not supported by protocol
Hi Elgs,
That message indicates that the kernel (on the host node) is not built with IPv6 support enabled.
Unfortunately, there’s nothing you could do in this case – other than putting in a support ticket with your host.
thanks a lot bro
I’ve found this for hours
now I find it!