basforge

Search titles, text and the “If it doesn’t work” cases.

    RU

    IPv6 in practice: address notation, fe80::, SLAAC, NDP, and ICMPv6 rules

    IPv6 expands addresses to 128 bits, drops broadcast and ARP, and moves neighbor discovery and autoconfiguration into ICMPv6. Covers :: shorthand, address classes, link-local fe80:: with %eth0 zone IDs, SLAAC address assignment, and why blocking all ICMPv6 on a firewall takes IPv6 completely offline.

    What you’ll get

    Inspect IPv6 addresses, routes, and the neighbor table on a Linux host right after it receives a Router Advertisement (SLAAC) and sends one ping:

    ip -6 addr show dev eth0
    # 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
    #     inet6 2001:db8:10:0:5054:ff:fe00:a/64 scope global dynamic mngtmpaddr
    #        valid_lft 86398sec preferred_lft 14398sec
    #     inet6 fe80::5054:ff:fe00:a/64 scope link
    #        valid_lft forever preferred_lft forever
    
    ip -6 route
    # 2001:db8:10::/64 dev eth0 proto kernel metric 256 expires 86397sec pref medium
    # fe80::/64 dev eth0 proto kernel metric 256 pref medium
    # default via fe80::5054:ff:fe00:1 dev eth0 proto ra metric 1024 expires 1797sec hoplimit 64 pref medium
    
    ip -6 neigh
    # 2001:db8:10::1 dev eth0 lladdr 52:54:00:00:00:01 router REACHABLE

    Two addresses live on the same interface at once: link-local fe80::… (scope link) and global 2001:db8:10:… (scope global dynamic), while the default gateway default via fe80::5054:ff:fe00:1 appeared on its own with proto ra. Behind the scenes, neighbor MAC resolution happened over ICMPv6 instead of ARP — here is that request in tcpdump:

    tcpdump -nn -i eth0 icmp6 · Pick a segment
    The neighbor replies with neighbor advertisement (type 136), and the kernel stores its MAC in ip -6 neigh as REACHABLE.

    Address notation: 128 bits and two shorthand rules

    An IPv6 address is 128 bits wide — four times the size of IPv4 (IPv4, masks, and CIDR). It is written as eight 16-bit hexadecimal groups (hextets) separated by colons:

    Full notation:      2001:0db8:0000:0000:0000:0000:0000:0001
    Drop leading 0s:    2001:db8:0:0:0:0:0:1
    Compress 0s to :::  2001:db8::1

    Two shortening rules and the RFC 5952 canonical form keep the same address identical across logs, configs, and firewall rules:

    1. Drop leading zeros in each group. 0db8 becomes db8, 000a becomes a, and 0000 becomes a single 0. Never drop trailing zeros: 0010 shortens to 10, not 1.
    2. Replace one longest run of all-zero groups with ::. You can use :: at most once per address — otherwise there is no way to tell how many zero groups each gap hides.
    3. Canonical form (RFC 5952): write a–f in lowercase; do not compress a single 0 group to :: (2001:db8:0:1::1, not 2001:db8::1:0:0:0:1); if two runs of zeros have the same length, compress the leftmost one.

    Check both canonical and expanded forms with Python’s built-in module:

    python3 -c 'import ipaddress; a=ipaddress.IPv6Address("2001:0db8:0000:0000:0000:0000:0000:0001"); print(a.compressed, a.exploded)'
    # 2001:db8::1 2001:0db8:0000:0000:0000:0000:0000:0001

    Whenever an IPv6 address sits next to a port number, wrap it in square brackets: http://[2001:db8:10::1]:8080/, [::1]:53, ssh -L [::1]:8080:127.0.0.1:80 web1. Without brackets, colons inside the address cannot be told apart from the colon before the port.

    Address classes and why a subnet is almost always /64

    Where IPv4 normally puts one address on an interface, IPv6 puts several at once, each with its own scope. Private addresses and NAT for address conservation are gone: a standard /64 subnet holds 2^64 addresses — more than the entire IPv4 space squared.

    Prefix Name IPv4 equivalent Where it appears
    ::1/128 Loopback 127.0.0.1/8 The host itself (localhost), local sockets
    ::/128 Unspecified 0.0.0.0 Listening on all IPv6 interfaces in ss ([::]:443), source address during DAD
    fe80::/10 Link-local 169.254.0.0/16 Auto-assigned on every interface; never crosses L2 boundaries
    fc00::/7 (fd00::/8) ULA (Unique Local) 10.0.0.0/8, 192.168.0.0/16 Internal networks and tunnels (WireGuard, office LAN) not routed on the internet
    2000::/3 GUA (Global Unicast) Public IPv4 Internet-routable addresses; ISPs delegate /56 or /48, each LAN takes a /64
    2001:db8::/32 Documentation 203.0.113.0/24 Reserved by RFC 3849 for examples; not routed on the internet
    ff00::/8 Multicast 224.0.0.0/4 and broadcast ff02::1 (all nodes on link), ff02::2 (all routers), ff02::1:ff00:0/104 (NDP)

    Why almost every LAN is a /64. The upper 64 bits are the network prefix and the lower 64 bits are the Interface ID. SLAAC works only with a /64 prefix: if you slice a subnet smaller (say /80 or /112), clients stop autoconfiguring addresses and need static config or DHCPv6. Exceptions show up in data centers and router-to-router links: a single host /128 and a point-to-point link /127 (RFC 6164, the IPv6 counterpart to IPv4 /31).

    Link-local fe80:: behavior. The kernel assigns a link-local address to every interface as soon as it comes up — before any router or config is involved. The default gateway in ip -6 route almost always points to the router’s fe80::… address because it stays constant even when the ISP changes your public prefix.

    The catch with fe80::/64 is that every network interface on the host (eth0, docker0, br-*) shares the same prefix. On a multi-interface server, ping -6 fe80::5054:ff:fe00:1 without an interface qualifier goes out whichever matching route comes first and drops packets. Specify the egress interface with a % zone suffix:

    # Without a zone on a multi-interface host, the packet goes out the wrong link:
    ping -6 -c 1 -W 1 fe80::5054:ff:fe00:1
    # 1 packets transmitted, 0 received, 100% packet loss
    
    # With %eth0, the kernel knows the exact egress interface:
    ping -6 -c 1 -W 1 fe80::5054:ff:fe00:1%eth0
    # 64 bytes from fe80::5054:ff:fe00:1%eth0: icmp_seq=1 ttl=64 time=0.068 ms

    The IPv6 header: 40 bytes and no in-path fragmentation

    An IPv6 header is twice as long as IPv4 (because of 16-byte addresses) but simpler in structure: the base header is always a fixed 40 bytes, with no header checksum (L2 and TCP/UDP already compute checksums) and no fragmentation fields. Intermediate routers are not allowed to fragment IPv6 packets — if a packet exceeds the next link’s MTU, the router drops it and sends back ICMPv6 Packet Too Big (type 2). The standard mandates a minimum MTU of 1280 bytes on every IPv6 link (ICMP and MTU).

    IPv6 frame on the wire · 1514 bytes (14 Ethernet + 40 IPv6 + 1460 payload)Pick a layer
    Ethernet header (L2)Rewritten at every router
    Dst MAC · 6 B52:54:00:00:00:01Next-hop gateway MAC learned via NDP (ip -6 neigh)
    Src MAC · 6 B52:54:00:00:00:0aSender NIC MAC address
    EtherType · 2 B0x86DDIPv6 code (IPv4 uses 0x0800, ARP uses 0x0806)
    Fixed IPv6 header (L3)Stays intact end-to-end (no NAT)

    No variable-length options, no checksum, no fragmentation fields: a router only inspects the address and Hop Limit.

    Src IPv6 · 16 B2001:db8:10:0:5054:ff:fe00:aSender global address (128 bits)
    Dst IPv6 · 16 B2001:db8:10::1Final destination (128 bits)
    Hop Limit · 1 B64, 63, …Direct equivalent of IPv4 TTL; at 0, the router sends ICMPv6 Time Exceeded
    Next Header · 1 B58 (ICMPv6) · 6 (TCP)Equivalent of IPv4 Protocol: 58 for ICMPv6, 6 for TCP, 17 for UDP
    IPv6 payloadSeen by sender and receiver

    At MTU 1500, TCP gets 1500 − 40 IPv6 − 20 TCP = 1440 bytes (MSS is 20 bytes smaller than in IPv4).

    ICMPv6 (Next = 58)NDP · SLAAC · PMTUDCarries error messages, ping, neighbor discovery, and autoconfiguration
    TCP / UDPsame as IPv4Same port numbers and handshake; the checksum pseudo-header includes the 128-bit addresses

    SLAAC and NDP: building a network without DHCP or ARP

    IPv4 relies on two separate mechanisms: ARP (an L2 protocol riding on broadcast ff:ff:ff:ff:ff:ff) and a DHCP server. IPv6 replaces both with NDP (Neighbor Discovery Protocol, RFC 4861) — a set of messages carried inside ICMPv6 (Next Header = 58):

    • SLAAC autoconfiguration (RFC 4862). When an interface comes up, the client sends a Router Solicitation (type 133) to the all-routers multicast address ff02::2. The router replies with a Router Advertisement (type 134, also sent periodically to ff02::1), advertising the /64 prefix, lifetimes, MTU, and whether DHCPv6 is needed. The client combines that prefix with its 64-bit Interface ID to build its global address, and sets the default gateway to the advertising router’s fe80::… address.
    • Duplicate Address Detection (DAD). Before activating a new address, the host sends a Neighbor Solicitation (type 135) from the unspecified source :: to its own candidate address. If nobody answers, the address is unused and moves from tentative to active.
    • Neighbor MAC resolution (replacing ARP). To find the MAC of 2001:db8:10::1, the client sends a Neighbor Solicitation (type 135) to its solicited-node multicast address ff02::1:ff00:1 (built from the last 24 bits of the target address). Only the target NIC accepts this multicast frame; other NICs filter it in hardware. The target answers with a Neighbor Advertisement (type 136) containing its MAC address.

    Where do the lower 64 bits come from in SLAAC? Classic EUI-64 takes the 48-bit MAC (for example 52:54:00:00:00:0a), inserts ff:fe in the middle, and flips the seventh bit of the first byte — yielding 5054:ff:fe00:a. Workstations and phones also turn on Privacy Extensions (RFC 4941, use_tempaddr = 2) so outgoing addresses rotate instead of exposing the device’s MAC to websites. Servers listed in DNS (AAAA) use a stable address (static, EUI-64, or RFC 7217).

    Why you can’t block all ICMPv6 on the firewall

    In IPv4, dropping all ICMP broke PMTUD and traceroute, yet local networking and ordinary connections still worked because ARP ran outside IP. In IPv6, all link-layer control (neighbor discovery, DAD, router advertisements, and Packet Too Big) lives inside ICMPv6. Worse, conntrack does not associate NDP messages with TCP flows, so ct state established,related accept does not let them through.

    Here is what happens on a live Linux host under three nftables setups (ip6 table, TCP port 8080 open):

    1. Router (RA)✓ 2001:db8:10::/64
    2. Client (DAD)✓ address free
    3. NDP (NS / NA)✓ MAC 52:54:00:00:00:01
    4. HTTP :8080✓ 200 OK
    19:06:17.542143 IP6 fe80::5054:ff:fe00:1 > ff02::1: ICMP6, router advertisement, length 56
    19:06:18.274373 IP6 :: > ff02::1:ff00:a: ICMP6, neighbor solicitation, who has 2001:db8:10:0:5054:ff:fe00:a
    19:06:19.979861 IP6 2001:db8:10:0:5054:ff:fe00:a > ff02::1:ff00:1: ICMP6, neighbor solicitation, who has 2001:db8:10::1
    19:06:19.979883 IP6 2001:db8:10::1 > 2001:db8:10:0:5054:ff:fe00:a: ICMP6, neighbor advertisement, tgt is 2001:db8:10::1
    What happened

    The client learned its prefix and default route from RA, verified its address via DAD, resolved the server MAC via NDP, and opened the TCP connection.

    Check with

    ip -6 addr, ip -6 route, and ip -6 neigh

    1. Client (curl)✓ sends NS for ::1
    2. nftables (drop)✕ dropped NS (type 135)
    3. Neighbor table✕ INCOMPLETE
    4. HTTP :8080✕ timeout (exit 28)
    $ curl -6 -sI --max-time 3 http://[2001:db8:10::1]:8080/
    # exit 28 (Connection timed out)
    $ ip -6 neigh
    2001:db8:10::1 dev eth0 INCOMPLETE
    Cause

    TCP port 8080 is open in the firewall, yet the SYN packet never even hit the wire: the client got no Neighbor Advertisement and never learned the server’s MAC.

    Check with

    ip -6 neigh (look for INCOMPLETE / FAILED) and sudo nft list ruleset

    1. Client✓ NS > ff02::1:ff00:1
    2. nftables✓ NDP allowed, echo blocked
    3. HTTP :8080✓ HTTP/1.0 200 OK
    $ curl -6 -sI http://[2001:db8:10::1]:8080/ | head -n 1
    HTTP/1.0 200 OK
    $ ping -6 -c 1 -W 1 2001:db8:10::1
    1 packets transmitted, 0 received, 100% packet loss
    What happened

    If the server should not answer ping, block only echo-request (type 128) and keep NDP and error types open.

    Check with

    sudo nft list chain ip6 filt input

    Minimum set of inbound ICMPv6 types (RFC 4890) required to keep IPv6 working:

    Type Name in nftables Purpose
    1 destination-unreachable Unreachable address or closed UDP port reports
    2 packet-too-big Foundation of Path MTU Discovery in IPv6 (counterpart to Fragmentation Needed)
    3 time-exceeded Expired Hop Limit, routing-loop protection, and traceroute/mtr
    4 parameter-problem Malformed packet header error reports
    133, 134 nd-router-solicit, nd-router-advert Router discovery, SLAAC prefix, and default gateway advertisement
    135, 136 nd-neighbor-solicit, nd-neighbor-advert Neighbor MAC resolution (NDP) and Duplicate Address Detection (DAD)

    In nftables, allow these types in one rule in the input chain before the drop policy (add echo-request if you want ping, nftables):

    icmpv6 type {
      destination-unreachable, packet-too-big, time-exceeded, parameter-problem,
      nd-router-solicit, nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert
    } accept

    What to check on Linux when debugging IPv6

    Every familiar networking command accepts -6:

    • ip -6 -br addr — interfaces and their IPv6 addresses (global, ULA, fe80::).
    • ip -6 route and ip -6 route get 2001:db8::1 — which interface, source address, and gateway the kernel picks.
    • ip -6 neigh — neighbor cache (counterpart to ARP cache): REACHABLE, STALE, INCOMPLETE, FAILED.
    • ping -6 <address> (append %eth0 for link-local) and tracepath -6 -n <address> — reachability and actual path MTU.
    • curl -6 -v https://example.org and dig AAAA example.org — force IPv6 and inspect DNS records.
    Which notation for `2001:0db8:0000:0000:0010:0000:0000:0001` follows RFC 5952?
    python3 -c 'import ipaddress; print(ipaddress.IPv6Address("2001:0db8:0000:0000:0010:0000:0000:0001"))'
    Which notation for `2001:0db8:0000:0000:0010:0000:0000:0001` follows RFC 5952?
    Answer:
    ipaddress.IPv6Address('2001:0db8:0000:0000:0010:0000:0000:0001').compressed -> '2001:db8::10:0:0:1'

    A double colon :: is allowed only once per address — otherwise you cannot tell how many zero groups each gap represents. When two zero runs tie in length, RFC 5952 compresses the leftmost one, and the trailing zero in 0010 stays: it is 10, not 1.

    A server allows `tcp dport 443 accept` with `policy drop` in the `ip6` table, yet LAN clients time out. What does `ip -6 neigh` show on the client?
    table ip6 filt {
      chain input {
        type filter hook input priority 0; policy drop;
        ct state established,related accept
        tcp dport 443 accept
      }
    }
    A server allows `tcp dport 443 accept` with `policy drop` in the `ip6` table, yet LAN clients time out. What does `ip -6 neigh` show on the client?
    Answer:
    2001:db8:10::1 dev eth0 INCOMPLETE

    IPv6 has no ARP: MAC resolution runs over ICMPv6 (nd-neighbor-solicit and nd-neighbor-advert). Until those types are allowed in input, the server kernel drops neighbor requests and the connection never reaches TCP SYN.

    If it doesn’t work

    After enabling the nftables firewall, the server stopped answering over IPv6 even though the TCP port is open

    Cause
    ICMPv6 is blocked: Neighbor Discovery (NS/NA) messages do not pass conntrack as established,related. Without them, clients and the gateway cannot learn the server’s MAC address, and entries in ip -6 neigh get stuck in INCOMPLETE.
    Fix
    Add a rule in the input chain allowing the mandatory icmpv6 types: nd-neighbor-solicit, nd-neighbor-advert, nd-router-solicit, nd-router-advert, packet-too-big, destination-unreachable, time-exceeded, and parameter-problem (nftables).

    ping -6 fe80::5054:ff:fe00:1 loses 100% of packets even though the neighbor is on the same segment and ip -6 neigh shows it

    Cause
    The fe80::/64 range is attached to several interfaces at once (eth0, docker0, br-* bridges) with the same metric. Without an interface specified, the kernel sends the packet out the wrong port.
    Fix
    Append the interface zone with %: ping -6 fe80::5054:ff:fe00:1%eth0 (in URLs, %25eth0).

    On a server running Docker or WireGuard, SLAAC IPv6 autoconfiguration stopped working and the default via fe80::… route vanished

    Cause
    Containers or routing turned on net.ipv6.conf.all.forwarding = 1. With accept_ra = 1, the Linux kernel stops accepting Router Advertisements on interfaces where forwarding is enabled.
    Fix
    Set net.ipv6.conf.eth0.accept_ra = 2 (accept RAs even with forwarding enabled) in /etc/sysctl.d/, or configure the address and gateway statically.

    curl http://2001:db8:10::1:8080/ or scp file 2001:db8:10::1:/tmp/ fails with an address parsing error

    Cause
    Colons inside the IPv6 address clash with the colon before the port number or file path.
    Fix
    Wrap the IPv6 address in square brackets: curl http://[2001:db8:10::1]:8080/ and scp file '[2001:db8:10::1]:/tmp/'.

    The interface has a global 2001:db8:…/64 address, yet IPv6 requests to external sites hang and fall back to IPv4

    Cause
    There is no default route (default via fe80::…) — either the router is not sending Router Advertisements, or the gateway is missing from the static netplan config.
    Fix
    Run ip -6 route and look for a default line. If it is missing, check accept_ra and whether nd-router-advert passes the firewall, or set the provider’s gateway manually.