Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host r1
r1(config)#int f0/0
r1(config-if)#ip addr 192.168.1.1 255.255.255.0
r1(config-if)#no ip redirects 在接口下关闭重定向功能
r1(config-if)#standby 192 ip 192.168.1.254 定义备份组,定义虚拟路由的ip地址
r1(config-if)#standby 192 priority 120 配置优先级为120
r1(config-if)#standby 192 preempt 配置占先权
r1(config-if)#no shut
r1(config-if)#exit
r1(config)#int f0/1
r1(config-if)#ip addr 202.106.1.1 255.255.255.0
r1(config-if)#no ip redirects 在接口下关闭重定向
r1(config-if)#standby 202 ip 202.106.1.254定义备份组,定义虚拟路由的ip地址
r1(config-if)#standby 202 priority 110 配置优先级
r1(config-if)#no shut
r1(config-if)#exit
r1(config)#int f1/0
r1(config-if)#ip addr 10.1.1.1 255.255.255.0
r1(config-if)#no shut
r1(config-if)#exit
r1(config)#ip route 192.168.1.0 255.255.255.0 10.1.1.2 配置静态路由
r1(config)#ip route 202.106.1.0 255.255.255.0 10.1.1.2
R2
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host r2
r2(config)#int f0/0
r2(config-if)#ip addr 202.106.1.2 255.255.255.0
r2(config-if)#no ip redirects 在接口下关闭重定向功能
r2(config-if)#standby 202 ip 202.106.1.254定义备份组,定义虚拟路由ip地址
r2(config-if)#standby 202 priority 120 配置优先级
r2(config-if)#standby 202 preempt 配置占先权
r2(config-if)#no shut
r2(config-if)#exit
r2(config)#int f0/1
r2(config-if)#ip addr 192.168.1.2 255.255.255.0
r2(config-if)#no ip re
r2(config-if)#no ip redirects 接口下关闭重定向
r2(config-if)#standby 192 ip 192.168.1.254 定义备份组,定义虚拟路由ip地址
r2(config-if)#standby 192 priority 110 配置优先级
r2(config-if)#no shut
r2(config-if)#exit
r2(config)#int f1/0
r2(config-if)#ip addr 10.1.1.2 255.255.255.0
r2(config-if)#no shut
r2(config-if)#exit
r2(config)#ip route 192.168.1.0 255.255.255.0 10.1.1.1 配置静态路由
r2(config)#ip route 202.106.1.0 255.255.255.0 10.1.1.1
配置完成后,让我们测试一下两边的PC机是否能相互ping通。如下显示,通信成功。
VPCS 1 >ping 202.106.1.6
202.106.1.6 icmp_seq=1 time=11.000 ms
202.106.1.6 icmp_seq=2 time=13.000 ms
202.106.1.6 icmp_seq=3 time=59.000 ms
202.106.1.6 icmp_seq=4 time=11.000 ms
202.106.1.6 icmp_seq=5 time=12.000 ms
VPCS 2 >ping 192.168.1.6
192.168.1.6 icmp_seq=1 time=9.000 ms
192.168.1.6 icmp_seq=2 time=9.000 ms
192.168.1.6 icmp_seq=3 time=11.000 ms
192.168.1.6 icmp_seq=4 time=12.000 ms
192.168.1.6 icmp_seq=5 time=9.000 ms
使用show standby 命令,查看路由器间HSRP的配置情况
首先在R1上查看,输出结果显示,
f0/0接口属于192备份组,优先级为120,配置了占先权,是活跃路由器;
f0/1接口属于202备份组,优先级为110,没有配置占先权,是备份路由器。
r1#show standby
FastEthernet0/0 - Group 192
Local state is Active, priority 120, maypreempt
Hellotime 3 holdtime 10
Next hello sent in 00:00:00.618
Hot standby IP address is192.168.1.254 configured
Active router is local
Standby router is 192.168.1.2expires in 00:00:08
Standby virtual mac address is0000.0c07.acc0
2 state changes, last state change00:21:24
FastEthernet0/1 - Group 202
Local state is Standby, priority 110
Hellotime 3 holdtime 10
Next hello sent in 00:00:02.896
Hot standby IP address is202.106.1.254 configured
Active router is 202.106.1.2expires in 00:00:07, priority 120
Standby router is local
6 state changes, last state change00:07:57
r2#show standby
FastEthernet0/0 - Group 202
Local state is Active, priority 120, maypreempt
Hellotime 3 holdtime 10
Next hello sent in 00:00:01.216
Hot standby IP address is202.106.1.254 configured
Active router is local
Standby router is 202.106.1.1expires in 00:00:07
Standby virtual mac address is0000.0c07.acca
2 state changes, last state change00:19:10
FastEthernet0/1 - Group 192
Local state is Standby, priority 110
Hellotime 3 holdtime 10
Next hello sent in 00:00:00.808
Hot standby IP address is192.168.1.254 configured
Active router is 192.168.1.1expires in 00:00:08, priority 120
Standby router is local
12 state changes, last statechange 00:02:28
r1#show standby brief
P indicatesconfigured to preempt.
|
Interface Grp Prio P State Active addr Standby addr Group addr
Fa0/0 192 120 P Active local 192.168.1.2 192.168.1.254
Fa0/1 202 110 Standby 202.106.1.2 local 202.106.1.254
r2#show standby brief
P indicatesconfigured to preempt.
|
Interface Grp Prio P State Active addr Standby addr Group addr
Fa0/0 202 120 P Active local 202.106.1.1 202.106.1.254
Fa0/1 192 110 Standby 192.168.1.1 local 192.168.1.254
接口shutdown以后,让我们来验证一下,PC机之间是否还能够相互通讯。
如下内容所示,PC机之间能够相互通讯。
VPCS 1 >ping 202.106.1.6
202.106.1.6 icmp_seq=1 time=11.000 ms
202.106.1.6 icmp_seq=2 time=13.000 ms
202.106.1.6 icmp_seq=3 time=59.000 ms
202.106.1.6 icmp_seq=4 time=11.000 ms
202.106.1.6 icmp_seq=5 time=12.000 ms
VPCS 2 >ping 192.168.1.6
192.168.1.6 icmp_seq=1 time=9.000 ms
192.168.1.6 icmp_seq=2 time=9.000 ms
192.168.1.6 icmp_seq=3 time=11.000 ms
192.168.1.6 icmp_seq=4 time=12.000 ms
192.168.1.6 icmp_seq=5 time=9.000 ms