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
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 gatewayFailover 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 eth0on Linux. A link-local next hop always needs the device. - Linux ignores RAs when forwarding is on unless
accept_rais set to 2.
They will ask next
Why is the gateway a link-local address and not the router's global address?
The link-local address is always there, does not change when the prefix is renumbered, and is unique on that link, which is all a next hop needs.
How do you stop a server from learning a default route from any RA on the segment?
Set its gateway statically and turn off RA processing (
accept_ra=0on Linux), and protect the segment with RA Guard so rogue RAs never reach it.
Traps
- Answering "DHCPv6 option 3". That is DHCPv4.
- Forgetting that a router lifetime of 0 removes the router from the default list.