6to4 on Linux

What is 6to4?

6to4 is the short name for Connection of IPv6 Domains via IPv4 Clouds. This is an Internet Draft by Brian Carpenter and Keith Moore describes a method to allow dynamic tunneling of IPv6 traffic between IPv6 sites without administrative tunnel setup. Naturally, the zero administration is a good thing...

So how do I get a free lunch?

Administrative tunnel setup is removed by using embedding the tunnel endpoints addresses in the IPv6 prefixes.

Essentially, an IPv6 prefix, 2002::/16 has been allocated to the scheme, and sites can automatically obtain address space from this prefix, by inserting the globally unique IPv4 address of an interface on your target 6to4 gateway into the IPv6 NLA. This is illustrated in the draft[1]:

 | 3 |  13  |    32     |   16   |          64 bits               |
 +---+------+-----------+--------+--------------------------------+
 |FP | TLA  | V4ADDR    | SLA ID |         Interface ID           |
 |001|0x0002|           |        |                                |
 +---+------+-----------+--------+--------------------------------+
If, for instance, the address of an interface on your 6to4 gateway was 32.33.34.35, then your site can use the IPv6 prefix 2002:2021:2223::/48. If you have a dynamic IP address, for instance via typical ISP dialup (like me), then converting your assigned IP address into hexdecimal is a pain - and you might appreciate the fact that in bash
export IP=32.33.34.35
printf "2002:%x%02x:%x%02x:\n" `echo ${IP} | sed 's/\./ /g'`
outputs 2002:2021:2223:.

How do I set it up?

This assumes dialup ppp - if this is not your case, you best use Peter Bieringer's scripts.

If we assume that you have IPv6 support in your linux kernel then, and also have the Kuznetsov's iproute2 tools, but don't have a connection to the 6bone, AND you use dynamic PPP access, you can run the following fragment in /etc/ppp/ip-up.local (don't forget to make it executable):

IP=$4
# I use microsoft's 6to4 site - more at http://www.kfu.com/~nsayer/6to4/
SIX2FOURGW=131.107.65.121
quads=`echo ${IP} | sed 's/\./ /g'`
prefix=`printf "2002:%x%02x:%x%02x:\n" ${quads}`
ip link set sit0 up     # we want sit0 running in wildcard send/receive mode
ip addr add ${prefix}:1 dev sit0    # simplest case...
ip route add 2002::/16 dev sit0     # route to 6to4 land via sit0
ip route add 2000::/3 via ::${SIX2FOURGW}
ip route add 3ffe::/16 via ::${SIX2FOURGW}
# fix up radvd.conf
cat /etc/radvd.conf.template | sed "s/THE6TO4/${prefix}0001::0/" > /etc/radvd.conf
kill -HUP `pidof radvd`
It is practice to form the device ID from the 6to4 gateway IPv4 address. Using the local IP addresses like this (should) guarantee uniqueness across your site.

Testing

At this point, if you do a traceroute6 to some site, say www.kame.net, while running a nifty packet sniffer like ethereal, you'll be able to see that the site that is tunneling IPv6 address space back to you tends to stay relatively constant. This is because just a few sites are acting as 6to4 gateways that advertise the 2002::/16 prefix into the 6bone, and so other sites send their traffic destined for your 6to4 address back via these few sites.

Beware: if you want to set your box up as a gateway, there are several more steps. Ideally, you should run a router advertisement daemon like radvd, but this won't work so well if you have dynamically assigned IP. You also will need to turn on IPv6 forwarding, echo 1 > /proc/sys/net/ipv6/conf/all/forwarding, for instance.

Typical scenario

The typical usage manner would be to use a static IP address, and the DNS for your systems would list their 2002:: prefix addresses. Other IPv6 domains would then resolve names to 2002:: addresses, and their 6to4 gateway would automatically tunnel packets to your sites IPv4 address as indicated in your 6to4 prefix.

Advanced 6to4...

For more complicated situations, where your site is peering with other ASes via a routing protocol such as BGP4+ etc., refer to [1].



[1] Connection of IPv6 Domains via IPv4 Clouds (work in progress), B. Carpenter & K. Moore, draft-ietf-ngtrans-6to4-06.txt http://www.ietf.org/internet-drafts/draft-ietf-ngtrans-6to4-07.txt Note: newer versions may have replaced this at a later date.

Bugspotters: Felix "Leitner", ... your name could be here :-)