Hot standby router protocol (HSRP)
- Cisco proprietary, RFC 2281
- TTL = 1
- version 1:
- IP dst: 224.0.0.2
- MAC dst: 0100.5e00.0002
- UDP 1985
- IP src: own
- MAC src:
- Standby/Listen: own MAC
- Active: 0000.0c07.ac××, ×× – group number
- version 2:
- IPv4 dst: 224.0.0.102
- IPv6 dst: ff02::66
- MAC dst: 0100.5e00.0066 (IPv4), 3333.0000.0066 (IPv6)
- UDP 1985 (IPv4), UDP 2029 (IPv6)
- IPv4 src: own
- IPv6 src: own
- MAC src:
- Standby/Listen: own MAC
- Active:
- IPv4: 0000.0c9f.f×××, ××× – group number
- IPv6: 0005.73a0.0×××
- packet – BLOB of successive TLVs
- default priority: 100
- election:
- process:
- higher priority
- higher IP address
- on being elected, Active sends gratuitous ARP: bcast + UplinkFast (0100.0ccd.cdcd)
- preempt:
- Active: higher priority only, off by default
- Standby: priority and IP address, always on
- process:
- ICMP redirect
- suppressed, if nexthop is HSRP router
- sent, if nexthop is non-HSRP router
; group ≡ 0 if not specified
(config-if)# standby [<GROUP>] priority <N>
; IP must be in interface subnet, cannot be interface IP address, can be learned from Active
; secondary: enable on secondary IP
(config-if)# standby [<GROUP>] [ip <IP> [secondary]]
; disabled by default
; minimum: wait before preempt
; reload: wait after reboot before preempt
(config-if)# standby [<GROUP>] preempt [delay [minimum] <sec>] [reload <sec>]
(config-if)# standby [<GROUP>] authentication <TEXT>
(config-if)# standby [<GROUP>] authentication md5 key-string [0|7] <PASS>
(config-if)# standby [<GROUP>] authentication md5 key-chain <CHAIN>
; DECR = 10 by default, several lines are possible
(config-if)# standby [<GROUP>] track <INTF> [<DECR>] [shutdown]
; copies HSRP_NAME state on the same physical interface
(config-if)# standby [<GROUP>] follow <HSRP_NAME>
(config-if)# standby version 2
(config-if)# standby bfd
; based on vMAC
(config-if)# standby ipv6 autoconfig
# show standby [brief] [<INTF>|vlan <ID>]
# show standby neighbors
# debug standby terse
Roles
- Active: single
- timers from Active are used by everyone
- Standby: single
- if receives frame for vMAC, forwards it further
- Listen: multiple
- do not send Hello
States
- Learn (Hello from Active not seen, does not know vIP)
- Listen (Hello from Active not seen, knows vIP)
- Speak (participates in election)
- Standby
- Active
Timers
- Hello: 3s default
- Hold: 10s default
- Advertise: 30s default
- best practice:: 3 × hello < hold
; hello < hold
(config-if)# standby [<GROUP>] timers [msec] <HELLO> [msec] <HOLD>
; Advertisement timer
(config-if)# standby [<GROUP>] redirect timers <ADV> <HOLD>
Messages
- Hello (sent by Active and Standby)
- Coup (sent on Active preemption attempt)
- Resign (release Active status, e.g., on shutdown)
- Advertise (sent by Listen)
Packet formats
HSRPv1 packet
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Version | Opcode | State | Hello time |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Hold time | Priority | Group | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|_ AuthData _|
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Virtual IP address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Version: 0x00
Hello time: seconds
Hold time: seconds
AuthData: cisco by default, clear-text password
Opcode:
- 0x00: Hello
- 0x01: Coup
- 0x02: Resign
- 0x03: Advertise
State:
- 0x00: disabled (initial)
- 0x01: Learn
- 0x02: Listen
- 0x04: Speak
- 0x08: Standby
- 0x10: Active
HSRPv1 Advertise
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Version | 0x03 | Advertisement type |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Advertisement length | Adv State | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Active groups | Passive group |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Advertisement type:
- 0x01: HSRP interface state
Advertisement state:
- 0x01: dormant
- 0x02: passive
- 0x03: active
Active groups: number of group, for which router is Active/Standby
Passive groups: number of group, for which router is Listen or vIP is unknown
HSRPv2 TLVs
- length – TLV data without header
- 0x01: group state
- 0x02: interface state TLV
- 0x03: text authentication
- 0x04: MD5 authentication
Interface state TLV
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | Length | Active groups |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Passive groups |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Group state TLV
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Version | Opcode | State | IP version |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Group | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
| Identifier (physical MAC) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Priority |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Hello time |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Hold time |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
\ \
/ Virtual IP /
\ \
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Version: 0x02
Hello time: ms
Hold time: ms
Opcode:
- 0x00: Hello
- 0x01: Coup
- 0x02: Resign
- 0x03: Advertise
State:
- 0x00: disabled (initial)
- 0x01: Learn
- 0x02: Listen
- 0x04: Speak
- 0x08: Standby
- 0x10: Active
Text authentication TLV
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|_ AuthData _|
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
AuthData: cleartext, cisco by default
MD5 authentication TLV
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| MD5 Algorithm | Padding | MD5 flags |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sender IP address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| MD5 key ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|_ _|
|_ MD5 AuthData _|
|_ _|
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Sender IP address: for IPv6 – last 4 bytes of link-local sender IP address
MD5 Algorithm:
- 0x01: MD5
mHSRP
- load-balancing
- ICMP redirect: to Active in other group or to non-HSRP
Design
- preempt delay = 1.5 × boot time
- do not use with VSS