R1配置
r1(config)#int lo0
r1(config-if)#ip add 1.1.1.1 255.255.255.0
r1(config-if)#int f0/0
r1(config-if)#ip ad 192.168.0.1 255.255.255.0
r1(config-if)#no sh
r1(config-if)#^Z
R2配置
r2(config)#int lo0
r2(config-if)#ip ad 2.2.2.2 255.255.255.0
r2(config-if)#int f0/0
r2(config-if)#ip ad 192.168.0.2 255.255.255.0
r2(config-if)#no sh
r2(config-if)#^Z
R1配置HSRP
r1#config t
r1(config)#int f0/0
r1(config-if)#standby 1 ip 192.168.0.10
r1(config-if)#standby 1 priority 150
r1(config-if)#standby 1 track lo0
r1(config-if)#standby 1 preempt
r1(config-if)#
R2配置HSRP
r2#config t
r2(config)#int f0/0
r2(config-if)#standby 1 ip 192.168.0.10
r2(config-if)#standby 1 track lo0
r2(config-if)#standby 1 preempt
r2(config-if)#^Z
R3配置成PC机
r3(config)#int f0/0
r3(config-if)#ip ad 192.168.0.3 255.255.255.0
r3(config-if)#no sh
r3(config)#no ip routing
r3(config)#ip default-gateway 192.168.0.10
r3(config)#^Z
R3 ping虚拟地址
r3#ping 192.168.0.10
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.10, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/39/68 ms
R1查看hsrp
r1#sh standby
FastEthernet0/0 �C Group 1
State is Active
2 state changes, last state change 00:02:07
Virtual IP address is 192.168.0.10
Active virtual MAC address is 0000.0c07.ac01
Local virtual MAC address is 0000.0c07.ac01 (default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 1.692 secs
Preemption enabled
Active router is local
Standby router is 192.168.0.2, priority 100 (expires in 8.728 sec)
Priority 150 (configured 150)
Track interface Loopback0 state Up decrement 10
IP redundancy name is “hsrp-Fa0/0-1″ (default)
r1#
r1#sh standby brief
P indicates configured to preempt.
|
Interface Grp Prio P State Active Standby Virtual IP
Fa0/0 1 150 P Active local 192.168.0.2 192.168.0.10
R1上模拟发生网络故障 关闭lo0
r1#config t
r1(config)#int lo0
r1(config-if)#sh
查看hsrp状态 r1成了Standby服务器
r1#sh standby brief
P indicates configured to preempt.
|
Interface Grp Prio P State Active Standby Virtual IP
Fa0/0 1 90 P Standby 192.168.0.2 local 192.168.0.10
对r1的lo0做端口追踪
r1(config)#int f0/0
r1(config-if)#standby 1 track lo0 60
r1(config-if)#^Z
并且打开lo0
r1#config t
r1(config)#int lo0
r1(config-if)#no sh
查看hsrp状态
r1#sh standby
FastEthernet0/0 �C Group 1
State is Active
5 state changes, last state change 00:00:24
Virtual IP address is 192.168.0.10
Active virtual MAC address is 0000.0c07.ac01
Local virtual MAC address is 0000.0c07.ac01 (default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 2.500 secs
Preemption enabled
Active router is local
Standby router is 192.168.0.2, priority 100 (expires in 7.564 sec)
Priority 150 (configured 150)
Track interface Loopback0 state Up decrement 60
IP redundancy name is “hsrp-Fa0/0-1″ (default)
r1#sh standby brief
P indicates configured to preempt.
|
Interface Grp Prio P State Active Standby Virtual IP
Fa0/0 1 150 P Active local 192.168.0.2 192.168.0.10
r2#sh standby brief
P indicates configured to preempt.
|
Interface Grp Prio P State Active Standby Virtual IP
Fa0/0 1 100 P Standby 192.168.0.1 local 192.168.0.10
r1再次成为 Active 而r2继续成为Standby