HSRP stands for Hot standby Router Protocol. HSRP is a First Hop Redundancy protocol which provides network availability even if the default gateway goes down( The first hop). In HSRP, the routers are grouped logically with a Virtual MAC and a Virtual IP Address. Require two or more routers to be in a group to provide redundancy.
The Virtual IP address must be configured in the host as default-gateway. The arp for this virtual ip address will map to the virtual MAC address of HSRP group routers in the Host device.
The routers must be configured in the same HSRP group. This way in one group, one router will be the active router and the other router will be on standby. They will be sharing a virtual IP and a virtual mac address. Both the routers will be sending hello packets to each other every 30 seconds but the standby router will be listening to the hello packets of the active routers. If it doesn’t receive the hello packet from the active router every 30 sec, It will become active itself, thus providing redundancy during failure of one default gateway.
R1#Conf t #int Gi0/0/0 # standby 1 ip virtual-default-gateway
R2#Conf t# int Gi0/0/0 # standby 1 ip virtual-default-gateway
where standby is HSRP command, 1 is the group number here, group number can be 0 – 255, 0 is default, virtual-default-gateway can be any IP for example: 10.0.0.1.
A single group in HSRP has same Virtual IP and same Virtual MAC address. All the packets received on the virtual IP address goes to the active router.
Active and Standby Decision between Routers are based upon the priority.
The default priority is 100, but we can change it using command:
#standby 1 priority 103
The range can be between 1 to 255. Highest number have the highest priority.
Note: If you change the priority of the standby router while there is an active router, the standby state won’t change until the preempt is enabled.
#conf t#int Gi0/0/0 # standby 1 preempt
How L2 Switches react to these:
The switches simply forward the packet. The mac table of the switch will contain the virtual mac address as well as the actual active router’s mac address attached to the same interface. The table below is the screenshot from packet tracer of the switch interface in the above topology:
The MAC Address 0001.0c07.ac01 is the virtual MAC, where 01 in ac01 is the groupid 1 and 0001.c9d4.8401 is the active router’s mac address. They are mapped to the same interface Fa0/4 here.