6to4 is one mechanism used for the transition of IPv4 to IPv6, precisely to route packets to an IPv6 network through an IPv4 network.
Let’s see how the IPv6 Internet knows how to route packets to your LAN with 6to4.
The principle of 6to4 is that there’s an association between your public registered IPv4 addresses and an IPv6 network. Your IPv4 address is contained in an IPv6 network starting with 2002::/16.
So, if the IPv4 public address of your gateway is 18.104.22.168, then your IPv6 network will be 2002:c233:341::/48 (leaving 16 bits for subnets). These are the IPv6 addresses that will be used when you connect to the IPv6 internet. For example, if you connect to the IPv6 version of Google, Google web server will reply a 2002:c233:341::/48 address, and will find a way for the packets to reach your network through the IPv4 internet.
Then, the principle is quite simple :
1) the 6to4 2002::/16 network is advertised by 6to4 gateways at the border between the IPv4 and IPv6 internets
2) When IPv6 Google wants to reach a host on a 2002::/16 network, it sends the packets to the 6to4 gateway
3) When the gateway receives packets for a 2002::/16 network, it understands it has to encapsulate the IPv6 packet inside an IPv4 packet :
a) For example, the 6to4 gateway receive a packet from the IPv6 Google to 2002:c233:341::1 address
b) It extracts the IPv4 address from the IPv6 destination address : 22.214.171.124
c) It encapsulates the IPv6 packet inside an IPv4 with destination IP address 126.96.36.199 and sends that on the IPv4 Internet to your gateway
4) Your gateway receives the IPv4 packet, de-encapsulate the IPv6 packet and sends it to your host.
This method is quite dynamic and simple. Each time a 2002::/16 network and the IPv6 internet need to communicate, a dynamic network is created between your IPv4 gateway and the 6to4 gateway, encapsulating the IPv6 packets inside IPv4.
Next time we’ll see what are the disadvantages of 6to4 and how 6rd solves them.