arrow_upward

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HE IPv6 Tunnel for OpenVZ Containers
#1
HE IPv6 Tunnel for OpenVZ Containers


Want to have IPv6 on your VPS but your hosting company doesn't provide one? Want to be future proof your server or let IPv6 users access your website over IPv6? Then read my guide! This will teach you how to use the HE tunnel on your OpenVZ container without contacting your host for IPv6 IPs!
NOTE: Refer to https://freevps.us/thread-16343-post-188...#pid188783 for systemd Distros (CentOS 7/Debian 8/ETC.)

Requirements:
TUN/TAP Adapter Enabled
iproute
gcc
Almost any Linux OS

First, you need to register on Hurricane Electric (Obviously).
URL: https://tunnelbroker.net/register.php
[Image: 9a7dcdcb0798d5e3e73b53e87eefd91f.png]
Once you are finished registering, you can move now on to the next step.


Then, Lets start creating our tunnel.
URL: https://tunnelbroker.net/new_tunnel.php

First, Input your Server IP Address in the text box.
[Image: 3f009a67ca0b4b26871ea4420db78ce0.png]

Next, Find the Tunnel Server that is closest to the location of your OpenVZ server.
(I'd recommend you to ping it, then ping the others and find the one with the lowest latency)
[Image: f14a48a2bb30b44b1ac626932c7a81dd.png]

Next, the most exciting part, the part where we connect it!
All the Info we need from that page is:
Server IPv4 Address
[font=arial, sans-serif]Client IPv4 Address[/font]
[font=arial, sans-serif][font=arial, sans-serif]Client IPv6 Address[/font][/font]
[font=arial, sans-serif][font=arial, sans-serif][font=arial, sans-serif]Routed /64[/font][/font][/font]
[font=arial, sans-serif][font=arial, sans-serif][font=arial, sans-serif][Image: a1bf1d370425f687813c431e8dbb7f22.png][/font][/font][/font]

[font=arial, sans-serif][font=arial, sans-serif][font=arial, sans-serif]We need to compile and install a tiny program that we will use to tunnel[/font][/font][/font]
cd ~ #Lets Go to our home Dir

wget https://tb-tun.googlecode.com/files/tb-tun_r18.tar.gz #Lets get the source code!

tar -xvf tb-tun_r18.tar.gz #Why not extract it?

gcc tb_userspace.c -l pthread -o tb_userspace #Compile it!

mv tb_userspace /usr/bin/tb_userspace #Move it over to the bin folder

chmod +x /usr/bin/tb_userspace #Make it executable of course!. How would it run if it wasnt?
Lets Create the Init.d script!
nano /etc/init.d/ipv6hetb
Paste it in there with the require info

#!/bin/bash
touch /var/lock/ipv6hetb
 
 #Variables
 SERVER_IP4_ADDR="0.0.0.0" #Server IP From Hurricane Electric
 CLIENT_IP4_ADDR="0.0.0.0" #Your server IPv4 Address
 CLIENT_IP6_ADDR="::/64" #Client IPv6 Address from Hurricane Electric
 ROUTED_IP6_ADDR="::/64" #Your Routed IPv6 From Hurricane Electric
 
 
 
case "$1" in
  start)
    echo "Starting ipv6hetb "
      setsid tb_userspace tb $SERVER_IP4_ADDR $CLIENT_IP4_ADDR sit > /dev/null 2>&1 &
      sleep 3s
      ifconfig tb up
      ifconfig tb inet6 add $CLIENT_IP6_ADDR
      ifconfig tb inet6 add $ROUTED_IP6_ADDR
      ifconfig tb mtu 1480
      route -A inet6 add ::/0 dev tb
      route -A inet6 del ::/0 dev venet0
    ;;
  stop)
    echo "Stopping ipv6hetb"
      ifconfig tb down
      route -A inet6 del ::/0 dev tb
      killall tb_userspace
    ;;
  *)
    echo "Usage: /etc/init.d/ipv6hetb {start|stop}"
    exit 1
    ;;
esac
 
exit 0
Then press CTRL+X then press "y" then press enter

An example of the settings would be here
Spoiler Expand
#!/bin/bash
touch /var/lock/ipv6hetb
 
 #Variables
 SERVER_IP4_ADDR="216.218.226.238" #Server IP From Hurricane Electric
 CLIENT_IP4_ADDR="192.168.1.2" #Your server IPv4 Address
 CLIENT_IP6_ADDR="2005:490:c:6af::2/64" #Client IPv6 Address from Hurricane Electric
 ROUTED_IP6_ADDR="2005:490:d:6af::2/64" #Your Routed IPv6 From Hurricane Electric
 
 
 
case "$1" in
  start)
    echo "Starting ipv6hetb "
      setsid tb_userspace tb $SERVER_IP4_ADDR $CLIENT_IP4_ADDR sit > /dev/null 2>&1 &
      sleep 3s
      ifconfig tb up
      ifconfig tb inet6 add $CLIENT_IP6_ADDR
      ifconfig tb inet6 add $ROUTED_IP6_ADDR
      ifconfig tb mtu 1480
      route -A inet6 add ::/0 dev tb
      route -A inet6 del ::/0 dev venet0
    ;;
  stop)
    echo "Stopping ipv6hetb"
      ifconfig tb down
      route -A inet6 del ::/0 dev tb
      killall tb_userspace
    ;;
  *)
    echo "Usage: /etc/init.d/ipv6hetb {start|stop}"
    exit 1
    ;;
esac
 
exit 0

Then we should make it executable then run the service!
chmod +x /etc/init.d/ipv6hetb
service ipv6hetb start

Now we have IPv6 on our server!
Now lets verify it using
ifconfig
if you see a device called "tb" you followed this guide right!

Lets try pinging an IPv6 Server!
ping6 -c 4 google.com
If it successfully ran, You really have IPv6 now!

Now, on to adding IPv6 to Nginx
Nginx:
We just need to add this to our server block
listen [::]:80;
listen [::]:443 ssl; #if you use SSL

A typical example for the server block would be
Spoiler Expand
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
server_name localhost;

root /path/to/your/web/root/;
location / {
index index.html;
}
}

Apache Users: I intentionally didn't add this because I don't use Apache lol

Thanks to 4810
I used some of his guides as a "template" (Not literally) for making this
http://FreeVPS.club - Free VPSs!


Messages In This Thread
HE IPv6 Tunnel for OpenVZ Containers - by Conan - 09-12-2015, 06:27 PM

Possibly Related Threads…
Thread
Author
Replies
Views
Last Post
1,895
03-25-2020, 04:11 PM
Last Post: fChk

person_pin_circle Users browsing this thread: 1 Guest(s)
Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - Hyper Expert - Shadow Hosting - Bladenode - Hostlease - RackNerd - ReadyDedis - Limitless Hosting