Hot Standby Router Protocol (HSRP) configuration requires assigning virtual IP addresses to switch virtual interfaces and setting standby group priorities across two Layer 3 switches. This content covers the CLI commands used to deploy HSRP, verify active and standby roles, and enable preemption for automatic failover.
HSRP Configuration Commands
We're going to go over the commands used to roll out HSRP.
To set this up we're going to have to add another Layer 3 switch. What we have right now is this network set up right here. All the items in yellow, and this switch 4 right here, we're going to add now. We're going to let OSPF do its thing on this side of it, so it can automatically change the way it's routing based off of OSPF — we're not concerned with that level. What we need to do is set up on this side virtual IP addresses on these switch virtual interfaces, and then once we do that we also need to connect physically all of these different links here.
There's a lot of programming that happens here, where we need to configure these new interfaces on all of these switches and set it all up. I'm not going to cover all of that, because frankly the CCNA exam isn't going to require you to get really in depth into all of this. So what I'm going to do is jump onto those switch virtual interfaces, go over a few commands, a few show commands, and then end things at that point in time. We're not going to implement any of this long term; this is just going to be for the demo.
I'm on hq-s1. This is the Layer 3 switch that we have been working with. I'm consoled into it because I'm going to lose some connectivity as I go through these commands. Down below I'm pinging the switch on the other side of the network, so we can see when I lose connectivity.
I'm going to start out by going into the global configuration mode, and I'm going to get into interface VLAN 10. In interface VLAN 10 right now, the IP address assigned to it is the virtual IP address that I want to use, so I'm going to have to take that off as being the main IP address. But before I do that, it's going to complain that I have the secondary set and I need to take the secondary off first. So I'm going to take the secondary IP address off. This is where I lose SSH connectivity, because that's the IP address I was SSHed into.
The next thing that I'm going to do is remove the IP address that I want to use as my virtual IP address. I'm going to give it the new IP address, and I chose to do .2. I noticed that when I did the last command it lost connectivity across the network, so I'm going to give it a new IP address. I enter the new IP address in, so now that's .2. I can put the secondary back on so I'd be able to SSH into it again. So now I've got that set.
Now what I'm going to do is create the standby group. I'm going to have the standby group of 10.1.10.1, so I'm going to copy that and paste it into here so it can become the standby group. I'll enter that in, and even though it's a standby, this is going to become the active shortly. It's going through those different states; it doesn't want to step on any toes, just in case there's another device out there that's already responding to this. Once it determines that there isn't, it's going to start pinging and we're going to get connectivity — and there it goes. It's gone through all the states and it is now active.
I also chose this group, so it's group 10. It doesn't really matter what group this is; I chose 10 because it's part of VLAN 10, so that's why I put that in there.
Next I'm going to set the priority. I'm going to set the priority to 120, and that makes this preferred as being the active. So now that is set, and I've got all the commands set up on this Layer 3 switch 1.
Now I have to configure the other side of this. I've set up hqs4, so now I'm on the other side on switch four, and what I'm going to do is get into the global configuration mode of that. I need to get into the interface, so let's get into interface for VLAN 10. I need to give it an IP address that needs to be different than the other one, so I'm going to choose .3 on that.
Then I say that this is also standby group 10 with the IP address of 10.1.10.1, so now that's going to be the virtual IP address. I want the priority of this to be less than the other one's, so I'm going to choose 80 on this one — the default is 100, so this is less than the default. I get that entered in, and then I also want this to relinquish control if the other one does come back up, so that's this preempt command. I'll put the preempt command in there, and then we are all set.
So now this virtual IP is being responded to by the active one, and then what I could do is unplug that real fast and then make sure that this fails over to the standby.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →