Chapter 51 — When a router dies: VRRP and friends
In one sentence
Your devices have exactly one default gateway, so two routers share a fake IP address between them and one takes over instantly if the other fails.
The problem
Every device on your network has one default gateway (Chapter 13). If that router dies, everything is cut off — even if there's a perfectly good second router sitting next to it, because nobody is configured to use it.
You could reconfigure every device. You could rely on DHCP to hand out a new gateway (slow, and only on lease renewal). Neither is acceptable.
The idea
Two routers pretend to be one router.
Router A (priority 110) \
>--- VIRTUAL IP: 192.168.1.1
Router B (priority 100) / VIRTUAL MAC: 00:00:5e:00:01:01
Every device on the LAN uses 192.168.1.1 as its gateway.
They have no idea two routers exist.
Router A is MASTER: it answers ARP for the virtual IP and forwards traffic.
Router B is BACKUP: it sits silently, listening.
A sends a "still alive" message every second.
If B misses three of them (~3 seconds), B takes over:
- claims the virtual IP and virtual MAC
- sends a gratuitous ARP so switches update their tables (Chapter 6!)
- starts forwarding
Devices notice nothing except a ~3 second pause.
Because the MAC address moves too, devices don't even need to re-ARP — their existing ARP cache entry stays valid.
The protocols
| Name | Notes |
|---|---|
| VRRP | The open standard (RFC 5798). Use this. |
| HSRP | Cisco's proprietary equivalent. Same idea, different names (Active/Standby). |
| GLBP | Cisco; also shares the load between routers, not just failover |
| keepalived | The common Linux implementation of VRRP — also widely used for service VIPs, not just routers |
Two details that matter in practice
1. Track your uplink. A router that's alive but has lost its own internet connection is worse than useless — it'll happily be Master and blackhole everything. Interface tracking lowers its priority when the uplink fails, so the other router takes over.
2. Preemption. When the failed router comes back, should it take over again? Usually yes — but with a delay, so it has time to rebuild its routing tables first. Otherwise it becomes Master while it still has no routes.
Where you'll meet this
- Any office or data centre with redundant routers or firewalls
- Load balancers in a highly-available pair (
keepalived+ HAProxy is a classic) - Your cloud provider does the equivalent invisibly — the "virtual router" in a VPC is already redundant
- Modern data centres increasingly use anycast gateways (every switch answers for the same gateway address) instead, but VRRP is still everywhere
Practice (15 min)
# see VRRP on the wire if your network uses it
sudo tcpdump -i any -n 'vrrp or proto 112'
# a virtual MAC always starts 00:00:5e:00:01:xx -- check your ARP cache
ip neigh | grep -i '00:00:5e:00:01'
arp -a | grep -i '00:00:5e'
# what IS your gateway's MAC? Is it a virtual one?
ip neigh show $(ip route | awk '/default/{print $3; exit}')
If your gateway's MAC starts 00:00:5e:00:01, you're behind a VRRP pair right
now.
Thought exercise for notes.md: your gateway fails over. Which of these
survive, and which break?
- An in-progress file download (TCP)
- A video call (UDP)
- A ping
- An SSH session
(Answer: all of them survive if failover is fast enough. TCP retransmits the missing packets — Chapter 22 — and the SSH session continues. The video call drops a few hundred milliseconds of audio. This is precisely why TCP's reliability exists.)
Check yourself
- What problem does VRRP solve?
- What two things do the routers share?
- Why does the virtual MAC matter, not just the virtual IP?
- Why should a router track its uplink interface?
Further reading
- Video: "VRRP / HSRP Explained" — Practical Networking.
- Docs:
keepaliveddocumentation — the practical Linux implementation, with configuration examples you can run. - RFC 5798 — the VRRP spec; the state machine section is readable.
End of Part 12 — Milestone check
- I can explain distance-vector vs link-state
- I know why the OSPF default reference bandwidth is a problem
- I know that
ExStartmeans "check the MTU" - I can explain why
LOCAL_PREFbeatingAS_PATHshapes the internet - I can explain a BGP prefix hijack using longest-prefix match
- I understand how VRRP makes a gateway failure invisible