R1(config-if)#int lo0
R1(config-if)#ip add 10.1.1.1 255.255.255.0
R1(config-line)#int f0/0
R1(config-if)#no sh
R1(config-if)#ip add 192.168.1.2 255.255.255.0
R1(config-if)#standby ip 192.168.1.1
R1(config-if)#standby priority 120 (默认为
0组,配置接口优先级为
120)
R1(config-if)#standby preempt (配置抢占)
R1(config-if)#standby track lo0 30 (跟踪
loopback0口,
down后优先级降
30)
R1(config-if)#standby 1 ip 192.168.1.254 (配置组
1的虚拟网关地址,以备下游负载使用)
R1(config-if)#standby 1 priority 100(再设定组
1接口优先级为
100,
100为默认,这步可省)
R1(config-if)#standby 1 preempt (同样配置抢占)
|
R2(config-if)#int lo0
R2(config-if)#ip add 10.1.1.1 255.255.255.0
R2(config-if)#int f0/0
R2(config-if)#no sh
R2(config-if)#ip add 192.168.1.3 255.255.255.0
R2(config-if)#standby ip 192.168.1.1
R2(config-if)#standby priority 100
R2(config-if)#standby preempt
R2(config-if)#standby 1 ip 192.168.1.254
R2(config-if)#standby 1 priority 120
R2(config-if)#standby 1 preempt
R2(config-if)#standby 1 track lo0 30
|
R1#sh standby bri
P indicates configured to preempt.
|
Interface Grp Prio P State Active Standby Virtual IP
Fa0/0 0 120 P Active local 192.168.1.3 192.168.1.1
Fa0/0 1 100 P Standby 192.168.1.3 local 192.168.1.254
R2#sh standby bri
P indicates configured to preempt.
|
Interface Grp Prio P State Active Standby Virtual IP
Fa0/0 0 100 P Standby 192.168.1.2 local 192.168.1.1
Fa0/0 1 120 P Active local 192.168.1.2 192.168.1.254
|
PC1(config)#no ip routing
PC1(config)#ip default-gateway 192.168.1.1 (指定
PC1默认网关为组
0的虚拟
IP)
PC1(config)#int f0/0
PC1(config-if)#no sh
PC1(config-if)#ip add 192.168.1.10 255.255.255.0
PC2(config)#no ip routing
PC2(config)#ip default-gateway 192.168.1.254
PC2(config)#int f0/0
PC2(config-if)#no sh
PC2(config-if)#ip add 192.168.1.20 255.255.255.0 (指定
PC2默认网关为组
1的虚拟
IP)
|
PC1
#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
1 192.168.1.2 28 msec * 24 msec
PC2
#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
1 192.168.1.3 28 msec * 44 msec
|
R1#debug standby events
HSRP Events debugging is on
R1#config t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int lo0
R1(config-if)#shut
R1(config-if)#
*Mar 1 00:39:25.323: %TRACKING-5-STATE: 1 interface Lo0 line-protocol Up->Down
R1(config-if)#
*Mar 1 00:39:25.327: HSRP: Fa0/0 Grp 0 Track 1 object changed, state Up -> Down
*Mar 1 00:39:25.331: HSRP: Fa0/0 Grp 0 Priority 120 -> 90
R1(config-if)#
*Mar 1 00:39:27.323: %LINK-5-CHANGED: Interface Loopback0, changed state to administratively down
*Mar 1 00:39:28.011: HSRP: Fa0/0 Grp 0 Ignoring Coup (100/192.168.1.3 < 120/192.168.1.2)
*Mar 1 00:39:28.051: HSRP: Fa0/0 Grp 0 Hello in 192.168.1.3 Active pri 100 vIP 192.168.1.1
*Mar 1 00:39:28.051: HSRP: Fa0/0 Grp 0 Active router is 192.168.1.3, was local
*Mar 1 00:39:28.051: HSRP: Fa0/0 Grp 0 Standby router is unknown, was 192.168.1.3
*Mar 1 00:39:28.051: HSRP: Fa0/0 Grp 0 Active: g/Hello rcvd from higher pri Active router (100/192.168.1.3)
*Mar 1 00:39:28.051: HSRP: Fa0/0 Grp 0 Active -> Speak
*Mar 1 00:39:28.051: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 0 state Active -> Speak
*Mar 1 00:39:28.051: HSRP: Fa0/0 Grp 0 Redundancy "hsrp-Fa0/0-0" state Active -> Speak
*Mar 1 00:39:28.067: HSRP: Fa0/0 API MAC address update
R1(config-if)#
*Mar 1 00:39:28.323: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to down
R1(config-if)#
*Mar 1 00:39:38.051: HSRP: Fa0/0 Grp 0 Speak: d/Standby timer expired (unknown)
*Mar 1 00:39:38.055: HSRP: Fa0/0 Grp 0 Standby router is local
(马上变成standby)
*Mar 1 00:39:38.055: HSRP: Fa0/0 Grp 0 Speak -> Standby
*Mar 1 00:39:38.059: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 0 state Speak -> Standby
R1(config-if)#
*Mar 1 00:39:38.059: HSRP: Fa0/0 Grp 0 Redundancy "hsrp-Fa0/0-0" state Speak -> Standby
|
R2(config)#int lo0
R2(config-if)#shut
R2(config-if)#do sh standby
FastEthernet0/0 - Group 0
State is Standby
6 state changes, last state change 00:00:05
Virtual IP address is 192.168.1.1
Active virtual MAC address is 0000.0c07.ac00
Local virtual MAC address is 0000.0c07.ac00 (v1 default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 0.636 secs
Preemption enabled
Active router is 192.168.1.2, priority 120 (expires in 9.864 sec)
Standby router is local
Priority 100 (default 100)
IP redundancy name is "hsrp-Fa0/0-0" (default)
FastEthernet0/0 - Group 1
State is Standby
5 state changes, last state change 00:00:03
Virtual IP address is 192.168.1.254
Active virtual MAC address is 0000.0c07.ac01
Local virtual MAC address is 0000.0c07.ac01 (v1 default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 2.228 secs
Preemption enabled
Active router is 192.168.1.2, priority 100 (expires in 8.304 sec)
Standby router is local
Priority 90 (configured 120)
Track interface Loopback0 state Down decrement 30
IP redundancy name is "hsrp-Fa0/0-1" (default)
|
PC2#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
1 192.168.1.2 40 msec * 40 msec
PC2#ping 10.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/20/40 ms
PC2#
|