R1(config)#int lo0
R1(config-if)#ip add 10.1.1.1 255.255.255.0
R1(config-if)#int f0/0
R1(config-if)#no sh
R1(config-if)#ip add 192.168.1.2 255.255.255.0
R1(config-if)#vrrp 1 ip 192.168.1.1
R1(config-if)#vrrp 1 priority 200 (设置
VRRP组
1的优先级为
200)
R1(config-if)#vrrp 1 preempt (对组
1 开启抢占)
R1(config-if)#exit
R1(config)#track 10 int lo0 line-protocol (在全局模式下创建对象为
10的事件号)
R1(config-track)#int f0/0
R1(config-if)#vrrp 1 track 10 decrement 60(调用跟踪事件
10,发现上行链路
down后优先级会减
60)
R1(config-if)#vrrp 2 ip 192.168.1.254 (在此基础上再建立一个组
2,以备负载)
R1(config-if)#vrrp 2 priority 150
R1(config-if)#vrrp 2 preempt
|
R2(config-line)#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)#vrrp 1 ip 192.168.1.1 (设置组
1的虚
IP)
R2(config-if)#vrrp 1 priority 150 (针对组
1设置相应的优先级。这样
R1在组
1的状态为
backup)
R2(config-if)#vrrp 1 preempt
R2(config-if)#vrrp 2 ip 192.168.1.254
R2(config-if)#vrrp 2 priority 200
R2(config-if)#vrrp 2 preempt
R2(config-if)#exit
R2(config)#track 20 int lo0 line-protocol (在全局模式下创建对象为
20的事件号)
R2(config-track)#int f0/0
R2(config-if)#vrrp 2 track 20 decrement 60 (发现上行链路
down 降
60,这样
200-60<150就是
backup)
|
PC1(config)#no ip routing
PC1(config)#ip default-gateway 192.168.1.1
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
|
R1#sh vrrp
*Mar 1 01:01:57.243: %SYS-5-CONFIG_I: Configured from console by console
R1#sh vrrp
FastEthernet0/0 - Group 1
State is Master
Virtual IP address is 192.168.1.1
Virtual MAC address is 0000.5e00.0101
Advertisement interval is 1.000 sec
Preemption enabled
Priority is 200
Track object 10 state Up decrement 60
Master Router is 192.168.1.2 (local), priority is 200
Master Advertisement interval is 1.000 sec
Master Down interval is 3.218 sec
FastEthernet0/0 - Group 2
State is Backup
Virtual IP address is 192.168.1.254
Virtual MAC address is 0000.5e00.0102
Advertisement interval is 1.000 sec
Preemption enabled
Priority is 150
Master Router is 192.168.1.3, priority is 200
Master Advertisement interval is 1.000 sec
Master Down interval is 3.414 sec (expires in 2.778 sec)
|
R2#sh vrrp
FastEthernet0/0 - Group 1
State is Backup
Virtual IP address is 192.168.1.1
Virtual MAC address is 0000.5e00.0101
Advertisement interval is 1.000 sec
Preemption enabled
Priority is 150
Master Router is 192.168.1.2, priority is 200
Master Advertisement interval is 1.000 sec
Master Down interval is 3.414 sec (expires in 2.950 sec)
FastEthernet0/0 - Group 2
State is Master
Virtual IP address is 192.168.1.254
Virtual MAC address is 0000.5e00.0102
Advertisement interval is 1.000 sec
Preemption enabled
Priority is 200
Track object 20 state Up decrement 60
Master Router is 192.168.1.3 (local), priority is 200
Master Advertisement interval is 1.000 sec
Master Down interval is 3.218 sec
|
R1#sh vrrp brief
Interface Grp Pri Time Own Pre State Master addr Group addr
Fa0/0 1 200 3218 Y Master 192.168.1.2 192.168.1.1
Fa0/0 2 150 3414 Y Backup 192.168.1.3 192.168.1.254
|
R2#sh vrrp bri
Interface Grp Pri Time Own Pre State Master addr Group addr
Fa0/0 1 150 3414 Y Backup 192.168.1.2 192.168.1.1
Fa0/0 2 200 3218 Y Master 192.168.1.3 192.168.1.254
|
R1(config)#int lo0
R1(config-if)#shutdown
PC1#traceroute
*Mar 1 01:14:22.935: %SYS-5-CONFIG_I: Configured from console by console
PC1#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
1 192.168.1.3 1036 msec * 20 msec
|
R1#sh vrrp brief
Interface Grp Pri Time Own Pre State Master addr Group addr
Fa0/0 1 140 3218 Y Backup 192.168.1.3 192.168.1.1
Fa0/0 2 150 3414 Y Backup 192.168.1.3 192.168.1.254
R2#sh vrrp bri
Interface Grp Pri Time Own Pre State Master addr Group addr
Fa0/0 1 150 3414 Y Master 192.168.1.3 192.168.1.1
Fa0/0 2 200 3218 Y Master 192.168.1.3 192.168.1.254
|