HSRP LAB:
Lab Goal:
Configure HSRP for gateway redundancy and test the failover. Router A will be our primary
(Active) and Router B will be our backup (Standby).
Topology Reminder:
LAN: PCs -> Switch D -> Router A & Router B
WAN: Router A & Router B -> ISP1 & ISP2
Virtual Gateway IP: 192.168.10.1
Step 1: Build the Topology in GNS3
1. Drag and drop two routers (e.g., Cisco c7200) onto the canvas. Name them RouterA
and RouterB.
2. Drag and drop two more routers to act as your ISPs. Name them ISP1 and ISP2.
3. Drag and drop an Ethernet Switch. Name it SwitchD.
4. Drag and drop a VPCS (Virtual PC). We'll use one for testing.
5. Connect the devices:
o PC1 eth0 -> SwitchD GigabitEthernet0/0
o SwitchD GigabitEthernet0/1 -> RouterA GigabitEthernet0/0
o SwitchD GigabitEthernet0/2 -> RouterB GigabitEthernet0/0
o RouterA GigabitEthernet0/1 -> ISP1 GigabitEthernet0/0
o RouterA GigabitEthernet0/2 -> ISP2 GigabitEthernet0/0
o RouterB GigabitEthernet0/1 -> ISP1 GigabitEthernet0/1
o RouterB GigabitEthernet0/2 -> ISP2 GigabitEthernet0/1
6. Start all devices.
Step 2: Basic IP Configuration (ISPs and PC)
Let's get the non-HSRP devices configured first.
On ISP1:
text
ISP1> enable
ISP1# conf t
Enter configuration commands, one per line. End with CNTL/Z.
ISP1(config)# interface GigabitEthernet0/0
ISP1(config-if)# ip address 10.1.1.1 255.255.255.252
ISP1(config-if)# no shutdown
ISP1(config-if)# exit
ISP1(config)# interface GigabitEthernet0/1
ISP1(config-if)# ip address 30.1.1.1 255.255.255.252
ISP1(config-if)# no shutdown
ISP1(config-if)# end
On ISP2:
text
ISP2> enable
ISP2# conf t
ISP2(config)# interface GigabitEthernet0/0
ISP2(config-if)# ip address 20.1.1.1 255.255.255.252
ISP2(config-if)# no shutdown
ISP2(config-if)# exit
ISP2(config)# interface GigabitEthernet0/1
ISP2(config-if)# ip address 40.1.1.1 255.255.255.252
ISP2(config-if)# no shutdown
ISP2(config-if)# end
On PC1:
Double-click the PC to open its console.
text
PC1> ip 192.168.10.11/24 192.168.10.1
Checking for duplicate address...
PC1 : 192.168.10.11/24 gateway 192.168.10.1
Note: The gateway 192.168.10.1 doesn't exist yet, so pings will fail for now.
Step 3: Configure Router A (The Active Router)
Now, let's configure the primary router.
text
RouterA> enable
RouterA# conf t
Enter configuration commands, one per line. End with CNTL/Z.
! Configure the physical IP on the LAN interface
RouterA(config)# interface GigabitEthernet0/0
RouterA(config-if)# ip address 192.168.10.2 255.255.255.0
RouterA(config-if)# no shutdown
! Configure HSRP
RouterA(config-if)# standby 1 ip 192.168.10.1
RouterA(config-if)# standby 1 priority 110
RouterA(config-if)# standby 1 preempt
RouterA(config-if)# exit
! Configure WAN interfaces
RouterA(config)# interface GigabitEthernet0/1
RouterA(config-if)# ip address 10.1.1.2 255.255.255.252
RouterA(config-if)# no shutdown
RouterA(config-if)# exit
RouterA(config)# interface GigabitEthernet0/2
RouterA(config-if)# ip address 20.1.1.2 255.255.255.252
RouterA(config-if)# no shutdown
RouterA(config-if)# exit
! Configure default routes to the internet
RouterA(config)# ip route 0.0.0.0 0.0.0.0 10.1.1.1
RouterA(config)# ip route 0.0.0.0 0.0.0.0 20.1.1.1 10
RouterA(config)# end
RouterA# write memory
Building configuration...
[OK]
Step 4: Configure Router B (The Standby Router)
Next, configure the backup router.
text
RouterB> enable
RouterB# conf t
Enter configuration commands, one per line. End with CNTL/Z.
! Configure the physical IP on the LAN interface
RouterB(config)# interface GigabitEthernet0/0
RouterB(config-if)# ip address 192.168.10.3 255.255.255.0
RouterB(config-if)# no shutdown
! Configure HSRP (note the lower priority)
RouterB(config-if)# standby 1 ip 192.168.10.1
RouterB(config-if)# standby 1 preempt
RouterB(config-if)# exit
! Configure WAN interfaces
RouterB(config)# interface GigabitEthernet0/1
RouterB(config-if)# ip address 30.1.1.2 255.255.255.252
RouterB(config-if)# no shutdown
RouterB(config-if)# exit
RouterB(config)# interface GigabitEthernet0/2
RouterB(config-if)# ip address 40.1.1.2 255.255.255.252
RouterB(config-if)# no shutdown
RouterB(config-if)# exit
! Configure default routes to the internet
RouterB(config)# ip route 0.0.0.0 0.0.0.0 30.1.1.1
RouterB(config)# ip route 0.0.0.0 0.0.0.0 40.1.1.1 10
RouterB(config)# end
RouterB# write memory
Building configuration...
[OK]
Step 5: Verification - Check HSRP Status
Let's see if it worked.
On Router A:
text
RouterA# show standby
GigabitEthernet0/0 - Group 1
State is Active
2 state changes, last state change 00:01:15
Virtual IP address is 192.168.10.1
Active virtual MAC address is 0000.0c07.ac01
...
Active router is local
Standby router is 192.168.10.3
Priority 110 (configured 110)
...
Success! Router A is Active.
On Router B:
text
RouterB# show standby
GigabitEthernet0/0 - Group 1
State is Standby
1 state change, last state change 00:01:05
Virtual IP address is 192.168.10.1
Active virtual MAC address is 0000.0c07.ac01
...
Active router is 192.168.10.2
Standby router is local
Priority 100 (default 100)
...
Success! Router B is Standby.
Step 6: Testing the Failover
Time for the real test.
1. Start a continuous ping from PC1 to an outside address (like ISP1).
text
PC1> ping -t 10.1.1.1
You should see successful replies coming back.
2. Simulate the failure. Go to the console for Router A and shut down the LAN
interface.
text
RouterA# conf t
RouterA(config)# interface GigabitEthernet0/0
RouterA(config-if)# shutdown
3. Watch the ping on PC1. You will see it time out for one or two packets.
text
84 bytes from 10.1.1.1 icmp_seq=5 ttl=254 time=10.000 ms
84 bytes from 10.1.1.1 icmp_seq=6 ttl=254 time=10.000 ms
timeout
timeout
84 bytes from 30.1.1.1 icmp_seq=9 ttl=254 time=20.000 ms <-- It works again!
84 bytes from 30.1.1.1 icmp_seq=10 ttl=254 time=20.000 ms
Notice that the reply now comes from 30.1.1.1 because traffic is flowing through
Router B.
4. Verify Router B is now Active.
text
RouterB# show standby
GigabitEthernet0/0 - Group 1
State is Active
2 state changes, last state change 00:00:10
...
Active router is local
Standby router is unknown
...
Failover successful!
Step 7: Testing the Failback (Recovery)
Now, let's bring Router A back online.
1. On Router A, enable the interface again.
text
RouterA(config-if)# no shutdown
2. Watch the HSRP status. Because of the preempt command and Router A's higher
priority, it will take back the Active role.
o On Router B: show standby will show it has returned to the Standby state.
o On Router A: show standby will show it is Active again.
You have now successfully built, configured, and tested a redundant gateway setup using
HSRP in GNS3.