Labs / IP Addressing & NAT / IPv6

Lab 3 of 3 · IPv6

IPv6 dual stack: run both and see which one wins

Run IPv4 and IPv6 side by side, see which one wins and what breaks.

Start this lab 6 steps

The idea

IPv4 and IPv6 can't talk to each other, so most machines run both. Find out which one a machine picks, what a Firewall misses, and how a machine with no IPv4 still reaches old websites.

The list decides, not curl
The list decides, not curl
One cable, two of everything else
One cable, two of everything else
The rule only reads IPv4
The rule only reads IPv4
IPv4 starts 200 ms later
IPv4 starts 200 ms later
An IPv4 address inside an IPv6 one
An IPv4 address inside an IPv6 one
How the scanner reaches an IPv4 site
How the scanner reaches an IPv4 site

Steps

  1. Ask for both addresses

    ticketDesk, at Harbor Ferries, has an IPv4 address and an IPv6 address on one network card. That's dual stack: the machine runs both versions side by side.

    It needs both because the versions can't talk to each other. An IPv6 packet has a different layout, and a machine with only IPv4 can't read it.

    The internet couldn't change over in one day, so the plan, written down in 1996, was to give machines both and drop IPv4 later. In June 2026, about half of Google's users reached it over IPv6, so both are still here.

    DNS holds the two addresses under one name, in two kinds of record: A for IPv4, and AAAA for IPv6, four As because the address is four times as long.

    Ask for each record of timetable.ferry.lab, then fetch the page. It prints the sender it saw.

    ticketDesk:~# dig +short A timetable.ferry.lab
    ticketDesk:~# dig +short AAAA timetable.ferry.lab
    ticketDesk:~# curl -sS -m 3 http://timetable.ferry.lab/
  2. Follow each version out

    Dual stack shares the card and the cable. Almost everything else comes in pairs. Each version has its own addresses, its own routing table and its own way out through the Router, harborRouter.

    ticketDesk's IPv4 address is 10.0.1.10, one of the private addresses that can't cross the internet. You've seen what the site shows for IPv6. Now force IPv4 with curl -4, and see what it shows.

    Then read both routing tables. Each is a list of where packets go, and default is the line for everything else. ip route lists the table for IPv4, and ip -6 route the table for IPv6.

    ticketDesk:~# curl -sS -m 3 -4 http://timetable.ferry.lab/
    ticketDesk:~# ip route
    ticketDesk:~# ip -6 route
  3. Block the site at the router

    A Firewall rule on harborRouter decides which packets it passes on. Say the timetable site has started serving bad downloads, and nobody in the office should open it until the owner cleans it up.

    The site's address is 198.51.100.50, so add a rule that drops anything going there. On Linux, the classic tool is iptables. Its FORWARD list holds the rules for packets passing through a router.

    Then try the page by name from ticketDesk, as anyone in the office would, and once more with curl -4.

    harborRouter:~# iptables -v -I FORWARD -d 198.51.100.50 -j DROP
    ticketDesk:~# curl -sS -m 3 http://timetable.ferry.lab/
    ticketDesk:~# curl -sS -m 3 -4 http://timetable.ferry.lab/
  4. Break one side and watch the fallback

    Now the opposite fault: IPv4 works, and IPv6 is broken somewhere along the way. Real networks do this when a router or firewall drops IPv6 and sends no error, so a machine can't know until it tries.

    Early on, that was a serious problem. A program tried the IPv6 address, which sorted first, then sat through a time-out of many seconds before it tried IPv4. A small fault in IPv6 made working websites look dead.

    The lab has removed your rule and now drops IPv6 packets to the site. Fetch the page with curl -v, which reports each attempt. Then time it, and ping the site by name.

    ticketDesk:~# curl -sS -m 3 -v http://timetable.ferry.lab/
    ticketDesk:~# curl -sS -m 3 -w "connected in %{time_connect} s\n" http://timetable.ferry.lab/
    ticketDesk:~# ping -c 1 -w 2 timetable.ferry.lab
  5. Look at a machine with no IPv4

    Dual stack gives every machine an IPv4 address too, and the central body that hands out new ones gave out its last in 2011. So some networks give machines IPv6 alone. T-Mobile in the United States had moved to that by 2014.

    handScanner, on the docks, is IPv6-only. Sites with IPv6 are no trouble for it. Old sites are.

    notices.port.lab is the port's old website, on a server with one IPv4 address and no AAAA record. The first step said that the versions can't talk, so the scanner shouldn't be able to reach it.

    Read the scanner's addresses, then ask DNS for both kinds of record. The scanner asks a Recursive resolver on harborRouter, which is the DNS server that looks names up for this network.

    handScanner:~# ip addr show dev dockside
    handScanner:~# dig +short A notices.port.lab
    handScanner:~# dig +short AAAA notices.port.lab
  6. Watch the router translate

    harborRouter sends everything for 64:ff9b::/96 into NAT64, a translator. It reads the IPv4 address from the last 32 bits, rewrites the IPv6 packet as an IPv4 packet, and sends it on.

    Answers take the same trip backwards. Think of NAT, except that it changes the version as well as the address.

    Read the router's route. Then fetch the page from the scanner, while the lab records packets on the scanner's card and on the site's card. Then ping the site's real IPv4 address from the scanner.

    harborRouter:~# ip -6 route show 64:ff9b::/96
    handScanner:~# curl -sS -m 3 http://notices.port.lab/
    handScanner:~# ping -c 1 -w 1 203.0.113.60

Run these steps on real machines

Keep reading

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab