6to4 and 6rd Testing with CDRouter
6to4 and 6rd are IPv6-over-IPv4 transition technologies. They let a CPE provide IPv6 service to its LAN when its service provider’s access network supports only IPv4. The CPE derives a global IPv6 prefix from its IPv4 WAN address, and tunnels IPv6 packets inside IPv4 to a relay router that connects to the IPv6 Internet.
Native IPv6 has replaced these technologies in most service provider networks, but many CPE devices still implement them, and some service providers still rely on 6rd.
CDRouter simulates the relay router and the IPv6 network behind it, so you can verify a CPE’s 6to4 or 6rd functionality and run CDRouter’s IPv6 tests through its tunnel. For an overview of all of the IPv6 WAN modes and transition technologies that CDRouter supports, see IPv6 WAN Modes and Transition Technologies.
How 6to4 works
6to4 is defined in RFC 3056.
The prefix 2002::/16 is reserved for 6to4. A CPE with a public IPv4
address creates its own /48 prefix by combining 2002::/16 with its
32-bit IPv4 WAN address. It then advertises one or more /64 subnets of
that prefix on its LAN, using the remaining 16 bits as a subnet ID.
For example, a CPE with the IPv4 WAN address 12.12.12.2 (0c0c:0c02
in hex) has the 6to4 prefix 2002:c0c:c02::/48. With a subnet ID of
1, it advertises the prefix 2002:c0c:c02:1::/64 on its LAN.
The CPE, called a 6to4 router, sends IPv6 packets from its LAN in one of two ways:
- If the destination is another 6to4 address, the CPE extracts the IPv4 address from the destination address, and tunnels the packet directly to that address.
- If the destination is a native IPv6 address, the CPE tunnels the
packet to a 6to4 relay. Public 6to4 relays share the anycast IPv4
address
192.88.99.1, so the CPE always uses the nearest one.
In both cases, the IPv6 packet is encapsulated in an IPv4 packet with protocol number 41. The recipient removes the IPv4 header and processes the IPv6 packet normally.
Since 6to4 relays are operated by third parties outside the service provider’s control, 6to4 service is best effort. A relay might be far away, or misconfigured to drop some traffic. For this reason, RFC 7526 deprecates the 6to4 anycast relay mechanism.
How 6rd works
6rd (IPv6 Rapid Deployment), defined in
RFC 5969, is based on 6to4
but solves its reliability problem. Instead of 2002::/16, each
service provider uses one of its own IPv6 prefixes, called the 6rd
prefix. Instead of public relays, the service provider runs its own
6rd Border Relay (BR). Since the entire path is under the service
provider’s control, 6rd can provide production-quality IPv6 service.
The CPE builds its 6rd delegated prefix by appending its IPv4 WAN address to the 6rd prefix. All of the IPv4 addresses in a service provider’s 6rd domain often share the same leading bits. To save space in the prefix, the service provider can specify an IPv4 mask length, which is the number of leading bits to remove from the IPv4 address. The length of the 6rd delegated prefix is:
6rd prefix length + (32 - IPv4 mask length)
The CPE needs four parameters, which can be configured manually or provisioned in the DHCPv4 6rd option (option 212):
- The 6rd prefix
- The 6rd prefix length
- The IPv4 mask length
- The IPv4 address of the 6rd BR
The CPE tunnels packets for other CPEs in the same 6rd domain directly to them, and tunnels all other IPv6 packets to the BR. To the rest of the IPv6 Internet, addresses in the 6rd prefix look like any other native IPv6 addresses.
Because the IPv4 address only needs to be unique within the service provider’s 6rd domain, 6rd can work with private IPv4 WAN addresses.
6to4 is effectively a special case of 6rd, with a 6rd prefix of
2002::/16, an IPv4 mask length of 0, and a BR at 192.88.99.1.
How CDRouter simulates 6to4 and 6rd
When the IPv6 WAN mode is 6to4 or 6rd, CDRouter:
- Brings up the DUT’s IPv4 WAN connection, using the configured IPv4 WAN mode.
- Creates a 6to4 relay or 6rd BR on the WAN at the IPv4 address set by
ipv6RelayServer, with the IPv6 address set byipv6RelayServerGlobal. - Connects its simulated IPv6 network, including its IPv6 remote host and DNS servers, to the relay or BR. For 6to4, it also simulates other 6to4 hosts.
- Calculates the 6to4 or 6rd prefix that it expects the DUT to use,
based on the DUT’s IPv4 WAN address (
wanNatIp). - For 6rd, includes the 6rd option in its DHCPv4 server’s responses,
unless
ipv6rdDHCPv4Optionisno.
CDRouter reduces its IPv6 MTU on the WAN by 20 bytes to allow for the
IPv4 header added to each tunneled packet, and by more if the IPv4 WAN
mode is PPPoE, PPTP, or L2TP. For more information, see
IPv6 MTU concepts in CDRouter.
Requirements
6to4 and 6rd require the CDRouter IPv6 expansion, with IPv6 enabled.
6to4 and 6rd run over an IPv4 WAN connection, so
wanMode must be set to one of the IPv4 WAN modes:
static, DHCP, PPPoE, PPTP, or L2TP.
6to4 and 6rd are supported on the primary WAN interface only.
For 6to4, the DUT’s IPv4 WAN address should be a public address.
CDRouter logs a warning if wanNatIp is a private
address, since many devices don’t create a 6to4 tunnel without a public
IPv4 address. In addition, ipv6RemoteHost can’t be a
6to4 (2002::/16) address.
Configuring 6to4
To enable 6to4, set ipv6WanMode to 6to4. The default
relay addresses are usually suitable:
testvar supportsIPv6 yes
testvar ipv6WanMode 6to4
testvar ipv6RelayServer 192.88.99.1
testvar ipv6RelayServerGlobal 3001:51a:cafe::6
CDRouter calculates the DUT’s 6to4 prefix from
wanNatIp, which is normally the same as
wanIspAssignIp. To complete the /64 prefix that the DUT
uses on its LAN, set ipv6LanSubnetId to the 16-bit
subnet ID used by the DUT, in hex. See
Configuring the LAN below.
Configuring 6rd
To enable 6rd, set ipv6WanMode to 6rd, and configure
the 6rd parameters to match the DUT:
| Testvar | Description |
|---|---|
ipv6RelayServer |
IPv4 address of the 6rd BR. Choose an address that isn’t used by any other element in the test setup. |
ipv6RelayServerGlobal |
IPv6 address of the 6rd BR |
ipv6rdPrefix |
The 6rd prefix, with all bits after the prefix length set to 0. This testvar is required. |
ipv6rdPrefixLen |
The 6rd prefix length (default 32) |
ipv6rdIPv4MaskLen |
The number of leading bits to remove from the IPv4 address (default 0) |
ipv6rdDHCPv4Option |
Whether CDRouter’s DHCPv4 server includes the 6rd option (default yes) |
When the IPv4 WAN mode is DHCP and ipv6rdDHCPv4Option
is yes, CDRouter’s DHCPv4 server provisions the DUT with the 6rd
prefix, prefix length, IPv4 mask length, and BR address in the 6rd
option. Otherwise, configure these parameters on the DUT manually.
The following table shows how the 6rd delegated prefix is calculated for some example configurations:
| 6rd prefix | IPv4 mask length | IPv4 WAN address | 6rd delegated prefix | Subnet ID bits |
|---|---|---|---|---|
2010::/16 |
0 | 12.12.12.2 |
2010:c0c:c02::/48 |
16 |
2010:1234::/32 |
8 | 12.12.12.2 |
2010:1234:c0c:200::/56 |
8 |
2010:1234::/32 |
8 | 192.168.200.2 |
2010:1234:a8c8:200::/56 |
8 |
2010:1234::/32 |
0 | 12.12.12.2 |
2010:1234:c0c:c02::/64 |
0 |
In the second row, the IPv4 mask length of 8 removes the first 8 bits
of 12.12.12.2 (0c), and the remaining 24 bits (0c0c02) follow the
32-bit 6rd prefix.
Configuring the LAN
With 6to4 and 6rd, the DUT’s LAN prefix is determined by its IPv4 WAN address, so CDRouter calculates it automatically. You only need to set the parts of the LAN address that the DUT chooses itself:
ipv6LanSubnetIdis the subnet ID, in hex, that the DUT places between its 6to4 or 6rd prefix and the 64-bit interface ID. If the subnet ID is shorter than the available subnet bits, its leading bits are set to 0. For example, a value offmeans that all of the subnet bits are 0 except the last four.ipv6LanIpis the DUT’s LAN address. Only its interface ID is used, such as::1, or::%eui64%for an EUI-64 interface ID based on the DUT’s LAN MAC address. If the testvar includes a prefix, CDRouter ignores it.
If the 6rd delegated prefix is a /64, there are no subnet ID bits, so
set ipv6LanSubnetId to 0.
Example: 6to4 with SLAAC on the LAN
In this example, CDRouter’s DHCPv4 server assigns the public IPv4
address 12.12.12.2 to the DUT, and CDRouter creates a 6to4 relay at
the default anycast address 192.88.99.1. The DUT’s 6to4 prefix is
2002:c0c:c02::/48.
The DUT uses subnet ID 1, so it advertises the prefix
2002:c0c:c02:1::/64 on its LAN, and assigns itself the address
2002:c0c:c02:1::1. CDRouter’s LAN clients use SLAAC to configure
their addresses.
# -- IPv4 WAN configuration
testvar wanMode DHCP
testvar wanIspIp 12.12.12.1
testvar wanIspAssignIp 12.12.12.2
testvar wanNatIp 12.12.12.2
testvar wanIspMask 255.255.255.0
# -- IPv6 WAN configuration
testvar supportsIPv6 yes
testvar ipv6WanMode 6to4
testvar ipv6RelayServer 192.88.99.1
testvar ipv6RelayServerGlobal 3001:51a:cafe::6
# -- IPv6 LAN configuration
testvar ipv6LanMode autoconf
testvar ipv6LanIp ::1
testvar ipv6LanSubnetId 1
Example: 6to4 with DHCPv6 on the LAN
This example uses the same IPv4 and 6to4 configuration as the previous example, but CDRouter’s LAN clients use DHCPv6 to get their addresses from the DUT.
The DUT’s DHCPv6 address pool is ::2 through ::1f in its LAN
prefix, with ::3 and ::7 excluded. With the DUT’s LAN prefix of
2002:c0c:c02:1::/64, CDRouter expects addresses from
2002:c0c:c02:1::2 through 2002:c0c:c02:1::1f, except
2002:c0c:c02:1::3 and 2002:c0c:c02:1::7.
# -- IPv6 LAN configuration
testvar ipv6LanMode DHCP
testvar ipv6LanIp ::1
testvar ipv6LanSubnetId 1
testvar ipv6DhcpClientStart ::2
testvar ipv6DhcpClientEnd ::1f
testvar ipv6DhcpClientExclude "::3 ::7"
Example: 6rd
In this example, CDRouter’s DHCPv4 server assigns the IPv4 address
12.12.12.2 to the DUT, and provisions it with the 6rd prefix
2010:1234::/32, an IPv4 mask length of 8, and a BR at 172.16.1.10
in the DHCPv4 6rd option.
The DUT’s 6rd delegated prefix is 2010:1234:c0c:200::/56. The DUT
uses subnet ID 1, so it advertises the prefix 2010:1234:c0c:201::/64
on its LAN.
# -- IPv4 WAN configuration
testvar wanMode DHCP
testvar wanIspIp 12.12.12.1
testvar wanIspAssignIp 12.12.12.2
testvar wanNatIp 12.12.12.2
testvar wanIspMask 255.255.255.0
# -- IPv6 WAN configuration
testvar supportsIPv6 yes
testvar ipv6WanMode 6rd
testvar ipv6RelayServer 172.16.1.10
testvar ipv6RelayServerGlobal 3001:51a:cafe::6
testvar ipv6rdPrefix 2010:1234::
testvar ipv6rdPrefixLen 32
testvar ipv6rdIPv4MaskLen 8
testvar ipv6rdDHCPv4Option yes
# -- IPv6 LAN configuration
testvar ipv6LanMode autoconf
testvar ipv6LanIp ::%eui64%
testvar ipv6LanSubnetId 1
6to4 and 6rd test modules
The 6to4 and 6rd test modules verify that the DUT:
- Advertises the correct prefix and subnet ID on its LAN, and assigns itself a global address from that prefix
- Assigns DHCPv6 addresses from the correct prefix to its LAN clients
- Tunnels packets directly to other 6to4 or 6rd addresses, and tunnels all other packets to the relay or BR
- Uses its IPv4 WAN address as the source address of tunneled packets, and sets the Don’t Fragment flag correctly
- Handles fragmented tunneled packets
- Updates its LAN prefix and addresses, and continues forwarding traffic, when its IPv4 WAN address changes
- Stops advertising its prefix when the IPv4 WAN link goes down
Many of CDRouter’s other IPv6 test modules also run with 6to4 or 6rd enabled.
Troubleshooting
The DUT doesn’t create a 6to4 tunnel
If the DUT doesn’t create a 6to4 tunnel after its IPv4 WAN connection comes up, check that:
- 6to4 is enabled on the DUT.
- CDRouter assigns a public IPv4 address to the DUT. 6to4 isn’t
designed to work with private IPv4 addresses, and many devices don’t
create a 6to4 tunnel if their primary IPv4 WAN address isn’t a global
address. CDRouter logs a warning at startup if
wanNatIpis a private address.
The DUT’s LAN prefix doesn’t match the expected prefix
CDRouter calculates the expected LAN prefix from
wanNatIp, the 6rd testvars, and
ipv6LanSubnetId. Check that:
wanNatIpmatches the DUT’s IPv4 WAN address.- For 6rd, the DUT’s 6rd prefix, prefix length, and IPv4 mask length
match
ipv6rdPrefix,ipv6rdPrefixLen, andipv6rdIPv4MaskLen. ipv6LanSubnetIdmatches the subnet ID used by the DUT, and is0if the 6rd delegated prefix is a /64.