IPv6 Tunneling

We assume that you have an OpenLBR running Debian. If not, go back to OpenLbr.

Goal

The goal of the following steps is to show you how to connect your OpenLBR onto the IPv6 Internet. Once that is working, OpenVirtualInterface shows you how to connect your LBR mote onto the OpenLBR, and onto the Internet. Our goal for now is to have both the OpenLBR and the Internet host inside the IPv6 cloud, and to be able to ping back and forth between them.

Setting up a single tunnel

We use the topology depicted above. We assume that you have a Linksys NSLU2 'Slug' running Debian (as described in OpenLbr; we call it OpenLBR from now on), and an Internet host which is already connected to the IPv6 cloud. If that is not the case, you can build the multi-tunnel topology described in the sections below.

Note that we have populated the topology above with our IPv4/IPv6 address. You will have to change those to your own, obviously.

Testing connectivity in IPv4 world

Start your Internet host and OpenLBR, and connect them to the Internet.

Tip: use http://ip4.me/ to check your public IPv4 address.

From the Internet host:

# ping 136.152.171.124 (to itself)
# ping 72.52.104.74 (to the tunnel server)
# ping 128.32.33.137 (to the OpenLbr)

From the OpenLBR

# ping 128.32.33.137 (to itself)
# ping 72.52.104.74 (to the tunnel server)
# ping 136.152.171.124 (to the Internet host, this may fail*)
# netsh firewall set icmpsetting 8 enable

(remember, do not proceed as long as you don't 100% success on all of the above commands)

Register your tunnel

Tunnel broker is a free service created by Internet enthusiasts wishing to promote the use of IPv6. Their service allows you to set up a tunnel to connect your computer to the IPv6 cloud, through an IPv4 network.

Setting up the tunnel from the LBR

At the bottom of your tunnel details page, choose "Linux-route2" in the drop-down and click Show Config. Enter the commands into your OpenLBR. In my case, I enter:

# modprobe ipv6
# ip tunnel add opentunnel_1 mode sit remote 72.52.104.74 local 128.32.33.137 ttl 255
# ip link set opentunnel_1 up
# ip addr add 2001:470:1f04:98e::2/64 dev opentunnel_1
# ip route add ::/0 dev opentunnel_1
# ip -f inet6 addr

On the OpenLBR, you can then type ifconfig. The opentunnel_1 "virtual" interface should have been created:

opentunnel_1 Link encap:IPv6-in-IPv4
          inet6 addr: 2001:470:1f04:98e::2/64 Scope:Global
          inet6 addr: fe80::8020:2189/128 Scope:Link
          UP POINTOPOINT RUNNING NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Testing connectivity in IPv6 world

Tip: use http://ip6.me/ to check your public IPv6 address of the Internet host.

Note that, to force the use of IPv6 when issuing a ping, you use ping6 in Linux and ping -6 in Windows.

From the (Linux based) OpenLBR

# ping6 2001:470:1f04:98e::2 (to itself)
# ping6 2001:470:1f04:98e::1 (to the tunnel server)
# ping6 2607:f140:400:1176:c466:2699:5ef1:d477 (to the Internet host*)

From the (Windows based) Internet host:

# ping -6 2607:f140:400:1176:c466:2699:5ef1:d477 (to itself)
# ping -6 2001:470:1f04:98e::1 (to the tunnel server)
# ping -6 2001:470:1f04:98e::2 (to the OpenLbr)

Setting up two tunnels using two public IPv4 addresses

If your Internet host does provide the Internet Host with an IPv6 address, it needs to tunnel into the IPv6 cloud to obtain one. You therefore can set up a second tunnel with http://tunnelbroker.net/ (with one account, you are allowed to set up up to 5 tunnel for free).

After registering your second tunnel, you can ask http://tunnelbroker.net/ to output the command you use to set it up. under Vista, it looks something like this:

netsh interface teredo set state disabled
netsh interface ipv6 add v6v4tunnel opentunnel_2 128.32.33.68 72.52.104.74
netsh interface ipv6 add address opentunnel_2 2001:470:1f04:fe3::2
netsh interface ipv6 add route ::/0 opentunnel_2 2001:470:1f04:fe3::1
pause

You can save these lines in a file enable_opentunnel_2.bat. Then right click on it, and choose Run as administrator. The last line prevents the command window to close after the last command has been executed.

In command window, type

ipconfig /all

You should see opentunnel_2, which has appeared as a "virtual" interface:

Tunnel adapter opentunnel_2:

   Connection-specific DNS Suffix  . : EECS.Berkeley.EDU
   Description . . . . . . . . . . . : Microsoft Direct Point-to-point Adapater
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   IPv6 Address. . . . . . . . . . . : 2001:470:1f04:fe3::2(Preferred)
   Link-local IPv6 Address . . . . . : fe80::9ccc:e411:7ac1:bbe1%41(Preferred)
   Default Gateway . . . . . . . . . : 2001:470:1f04:fe3::1
   DNS Servers . . . . . . . . . . . : 128.32.33.21
                                       128.32.33.23
                                       128.32.206.12
   NetBIOS over Tcpip. . . . . . . . : Disabled

You can test your connection by pinging the different elements of your setup. A good practice is to ping from the closest element to the furthest, i.e.

Setting up two tunnels using a single public IPv4 addresses

Note that the IPv4 endpoint of each tunnel needs to be a unique. This creates a problem if your Internet Host and OpenLBR share a same IPv4 public address through NAT (which is typical in a home environment). Below is a possible topology.

We assume that your OpenLBR has already set up a tunnel, using the procedure described above. To be able to set up a second tunnel from your Internet Host, you need to obtain a different public IPv4 address; you can do this using a VPN connection. In our case, we use the UC Berkeley VPN service, but any other service will do. Once you set up this IPv4 tunnel, use http://ip4.me to learn your public IPv4 address. Use that address as the IPv4 endpoint of your second http://tunnelbroker.net/ tunnel. You can set up opentunnel_2 using (in Vista):

netsh interface teredo set state disabled
netsh interface ipv6 add v6v4tunnel IP6Tunnel 136.152.208.228 72.52.104.74
netsh interface ipv6 add address IP6Tunnel 2001:470:1f04:fe3::2
netsh interface ipv6 add route ::/0 IP6Tunnel 2001:470:1f04:fe3::1

Typing ipconfig /all lists all your interfaces:

You can test the connectivity by issuing a series on ping form the Internet host:

You can see how the average round-trip times increase. Note that you can test connectivity also from your OpenLBR, or from a mote in your OpenWSN network.

IPv6-in-IPv4Tunneling through an PPTP/VPN tunnel

You may want to establish the IPv6-in-IPv4 tunnel through a PPTP or VPN sessions for the following cases:

In the following example, we assume the latter case. We are using Cisco's AnyConnect to establish the VPN connection. The resulting interface is called cscotun0.

In case you are using a PPTP connection, simply replace cscotun0 by ppp0.

The following script opens the IPv6-in-IPv4 tunnel:

#!/bin/bash

echo 'Make sure the VPN/PPTP tunnel is active!'

addr=`ifconfig cscotun0 | sed -n '/inet addr:/s/.*addr:\([^ ]*\) .*/\1/p'`
echo "Using address $addr"

echo 'Configuring eth1'
ifconfig eth1 10.0.0.2 netmask 255.0.0.0
ifconfig eth1 inet6 add 2001:470:846d:2::1/64
ifconfig eth1 up
echo 'done.'

echo 'Bringing up the IPv6-in-IPv4 tunnnel...'
ifconfig sit0 up
ifconfig sit0 inet6 tunnel ::72.52.104.74
ifconfig sit1 up
ifconfig sit1 inet6 add 2001:470:1f04:1195::2/64
route -A inet6 add ::/0 dev sit1
echo 'done.'

echo 'Configuring IP routing...'
echo "1 admin" >> /etc/iproute2/rt_tables
ip route add default dev cscotun0 table admin
ip rule add from $addr table admin
echo 'done.'

echo 'Starting RADVD...'
/etc/init.d/radvd start
echo 'done.'

To close the tunnel:

#!/bin/bash

addr=`ifconfig cscotun0 | sed -n '/inet addr:/s/.*addr:\([^ ]*\) .*/\1/p'`

echo 'Stopping RADVD...'
/etc/init.d/radvd stop
echo 'done.'

echo 'Ending IP routing...'
ip rule del from $addr table admin
ip route del default dev cscotun0 table admin
sed "/1 admin/d" /etc/iproute2/rt_tables
echo 'done.'

echo 'Tearing down the IPv6-in-IPv4 tunnel...'
route -A inet6 del ::/0 dev sit1
ifconfig sit1 down
ifconfig sit0 down
echo 'done.'

echo 'Disabling eth1...'
ifconfig eth1 del 2001:470:846d:2::1/64
ifconfig eth1 down
echo 'done.'

echo 'You can now close the VPN/PPTP tunnel.'

If everything works, go on to Use a Virtual Interface.