Octet

How does an IPv6 host learn its default gateway? Can DHCPv6 give it one?

Show the answer

Say this first

Only from Router Advertisements, or from static configuration. Any RA with a non-zero router lifetime adds the sender's link-local address to the host's default router list. DHCPv6 has no gateway option. If two routers send RAs, the host learns both, picks one using the router preference field (high, medium, low) and falls back to the other when NUD finds the first unreachable, which takes tens of seconds.

Go deeper

What the host stores

  • Default router list: each router's link-local address and lifetime.
  • The router lifetime in the RA, 1800 s by default on IOS, sets how long the entry lives without a new RA.
  • A router lifetime of 0 means "I am not a default router", even though the RA can still carry prefixes.

Controls on IOS

Cisco IOS
interface GigabitEthernet0/0/0
 ipv6 nd router-preference high   ! RFC 4191, default is medium
 ipv6 nd ra lifetime 0            ! advertise prefixes but never be the gateway

Failover without an FHRP

A host only notices a dead router through NUD: the entry must leave REACHABLE (up to 45 s), then DELAY (5 s) and PROBE (3 s). Expect tens of seconds. For faster failover use HSRPv2 for IPv6 or VRRPv3, which give a virtual link-local address that moves between routers.

Servers and routers as hosts

  • Static: ip -6 route add default via fe80::1 dev eth0 on Linux. A link-local next hop always needs the device.
  • Linux ignores RAs when forwarding is on unless accept_ra is set to 2.

Traps

  • Answering "DHCPv6 option 3". That is DHCPv4.
  • Forgetting that a router lifetime of 0 removes the router from the default list.
How did you do?Book 4.2 IP Version 6