Intro
We have previously covered briefly how an IPv4 network can communicate with an IPv6 network. One of the methods is via an IPv6 tunnel. In this article, we’ll delve deeper into 6to4 which is an IPv6 tunneling mechanism. By using 6to4, IPv6 packets can be transmitted over an IPv4 network.
Also see Teredo tunneling.
How does 6to4 work?
For the 6to4 tunneling mechanism to work, there are a few key components required.
- The global IPv4 address for the tunnel interface.
- The dual-stack relay server to route IPv4 packets to the IPv6 interface and vice-versa.
- The 6to4 IPv6 address.
Calculating the 6to4 IPv6 address
First of all, we’ll take a look at how to derive the 6to4 IPv6 address from the IPv4 address. You can easily notice a 6to4 IPv6 address because the first 16 bits is always 2002 in hexadecimal (as specified in RFC 3056). Following the RFC specification, the next 32 bits will be the IPv4 address. After that, the next 16 bits will specify the particular IPv6 subnet.
For example, you have 2002:0C9B:A665:0001:0000:0000:0C9B:A665 as your 6to4 IPv6 address. Your IPv4 address will be 0C9B:A665 which you can view as 0C.9B.A6.65 then you can convert it to decimal to get 12.155.166.101 for your dotted-decimal IPv4 address notation.
Role of the relay server
The relay server is the one doing the actual routing of packets between IPv6 and IPv4. To do this job, the relay server will have both an IPv4 interface and an IPv6 interface.
Whenever a 6to4 packet arrives on the IPv4 interface, the IPv6 payload will be routed to the IPv6 network. During the reverse process, packets arriving on the IPv6 interface with a destination address prefix of 2002::/16 will be encapsulated and forwarded over the IPv4 network.
Performing encapsulation
As mentioned above, whenever packets come from the IPv6 network with a 6to4 IP address as the destination, it will be encapsulated and sent over the IPv4 network. To perform the encapsulation, an IPv4 packet with protocol type 41 will embed the IPv6 packets inside the IPv4 packet’s payload.
Conclusion
While there are still IPv4 hosts out there, there will still be a need for transition mechanisms like the 6to4 tunneling. This is why it’s important to learn about 6to4 tunneling.