The commands
On each router's LAN interface, with the same group number:
| Command | Does |
|---|---|
standby version 2 | Use HSRPv2 (more groups, IPv6 support). Both routers must match. |
standby 1 ip 192.168.10.1 | Join group 1 with this virtual IP |
standby 1 priority 110 | Higher wins (default 100) |
standby 1 preempt | Take over again when this router is better |
standby 1 track g0/1 20 | Lower the priority by 20 while Gi0/1 (the uplink) is down |
R1 should be in charge, so it gets priority 110. Configure both routers:
In NetLab
▶ R1 R1>enable R1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. R1(config)#interface g0/0 R1(config-if)#standby version 2 R1(config-if)#standby 1 ip 192.168.10.1 *Mar 1 00:00:05.000: %HSRP-5-STATECHANGE: GigabitEthernet0/0 Grp 1 state Speak -> Standby *Mar 1 00:00:05.000: %HSRP-5-STATECHANGE: GigabitEthernet0/0 Grp 1 state Standby -> Active R1(config-if)#standby 1 priority 110 R1(config-if)#standby 1 preempt R1(config-if)#standby 1 track g0/1 20 R1(config-if)#end *Mar 1 00:00:09.000: %SYS-5-CONFIG_I: Configured from console by console ▶ R2 R2>enable R2#configure terminal Enter configuration commands, one per line. End with CNTL/Z. R2(config)#interface g0/0 R2(config-if)#standby version 2 R2(config-if)#standby 1 ip 192.168.10.1 *Mar 1 00:00:14.000: %HSRP-5-STATECHANGE: GigabitEthernet0/0 Grp 1 state Speak -> Standby R2(config-if)#standby 1 preempt R2(config-if)#end *Mar 1 00:00:16.000: %SYS-5-CONFIG_I: Configured from console by console R2#show standby brief P indicates configured to preempt. | Interface Grp Pri P State Active Standby Virtual IP Gi0/0 1 100 P Standby 192.168.10.2 local 192.168.10.1 ▶ PC1 NetLab Windows-style command prompt. Type help to see the commands. C:\Users\student>ping 8.8.8.8 Pinging 8.8.8.8 with 32 bytes of data: Request timed out. Request timed out. Reply from 8.8.8.8: bytes=32 time<1ms TTL=254 Reply from 8.8.8.8: bytes=32 time<1ms TTL=254 Ping statistics for 8.8.8.8: Packets: Sent = 4, Received = 2, Lost = 2 (50% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms C:\Users\student>tracert 8.8.8.8 Tracing route to 8.8.8.8 over a maximum of 30 hops 1 <1 ms <1 ms <1 ms 192.168.10.2 2 2 ms 2 ms 2 ms 8.8.8.8 Trace complete.
A failover
Now R1's uplink fails. Tracking drops R1's priority to 90, so R2 (100, with preempt) takes over. The PCs keep using 192.168.10.1, and their traffic now goes through R2:
In NetLab
▶ PC1 NetLab Windows-style command prompt. Type help to see the commands. C:\Users\student>ping 8.8.8.8 Pinging 8.8.8.8 with 32 bytes of data: Request timed out. Reply from 8.8.8.8: bytes=32 time<1ms TTL=254 Reply from 8.8.8.8: bytes=32 time<1ms TTL=254 Reply from 8.8.8.8: bytes=32 time<1ms TTL=254 Ping statistics for 8.8.8.8: Packets: Sent = 4, Received = 3, Lost = 1 (25% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms ▶ R1 R1>enable R1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. R1(config)#interface g0/1 R1(config-if)#shutdown *Mar 1 00:00:09.003: %LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to administratively down *Mar 1 00:00:09.003: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to down *Mar 1 00:00:09.003: %HSRP-5-STATECHANGE: GigabitEthernet0/0 Grp 1 state Active -> Speak *Mar 1 00:00:09.003: %HSRP-5-STATECHANGE: GigabitEthernet0/0 Grp 1 state Speak -> Standby R1(config-if)#end *Mar 1 00:00:10.003: %SYS-5-CONFIG_I: Configured from console by console R1#show standby GigabitEthernet0/0 - Group 1 (version 2) State is Standby 2 state changes, last state change 00:00:02 Virtual IP address is 192.168.10.1 Active virtual MAC address is 0000.0c9f.f001 Local virtual MAC address is 0000.0c9f.f001 (v2 default) Hello time 3 sec, hold time 10 sec Preemption enabled Active router is 192.168.10.3, priority 100 (expires in 9.024 sec) Standby router is local Priority 90 (configured 110) Track interface GigabitEthernet0/1 state Down decrement 20 Group name is "hsrp-Gi0/0-1" (default) ▶ PC1 C:\Users\student>tracert 8.8.8.8 Tracing route to 8.8.8.8 over a maximum of 30 hops 1 * <1 ms <1 ms 192.168.10.3 2 * 2 ms 2 ms 8.8.8.8 Trace complete.
Common mistake: Without tracking, R1 would stay Active after its uplink failed: its LAN side is fine, so HSRP sees nothing wrong, and the PCs' traffic would be dropped at R1.