本文转载至http://mxn19871215.blog.51cto.com/982365/483601,作者mxn6341928
Router>en
Router#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#no ip domain-lookup
Router(config)#line con 0
Router(config-line)#no exec-timeout
Router(config-line)#loggin syn
Router(config-line)#exit
Router(config)#host pc1
pc1(config)#int e0/0
pc1(config-if)#no shut
pc1(config-if)#ip add 192.168.1.1 255.255.255.0
pc1(config-if)#exit
pc1(config)#
ip default-gateway 192.168.1.254 //
网关指向虚拟IP
Router>en
Router#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#no ip domain-lookup
Router(config)#line con 0
Router(config-line)#no exec-timeout
Router(config-line)#loggin syn
Router(config-line)#exit
Router(config)#host pc2
pc2(config)#int e0/0
pc2(config-if)#no shut
pc2(config-if)#ip add 192.168.2.2 255.255.255.0
pc2(config-if)#exit
pc2(config)#
ip default-gateway 192.168.2.254
pc2(config)#end
|
Router>en
Router#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#no ip domain-lookup
Router(config)#line con 0
Router(config-line)#no exec-timeout
Router(config-line)#loggin syn
Router(config-line)#exit
Router(config)#host R2
R2(config)#int e0/0
R2(config-if)#no shut
R2(config-if)#ip add 192.168.1.2 255.255.255.0
R2(config-if)#int e0/1
R2(config-if)#no shut
R2(config-if)#ip add 192.168.2.3 255.255.255.0
R2(config-if)#exit
R2(config)#int e0/0
R2(config-if)#
vrrp 10 ip 192.168.1.254 //
创建vrrp
组10
R2(config-if)#
vrrp 10 priority 150 //
修改优先级
R2(config-if)#
vrrp 10 preempt //
启用抢占功能
R2(config-if)#int e0/1
R2(config-if)#vrrp 20 ip 192.168.2.254
R2(config-if)#
|
Router>en
Router#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#no ip domain-lookup
Router(config)#line con 0
Router(config-line)#no exec-timeout
Router(config-line)#loggin syn
Router(config-line)#exit
Router(config)#host R3
R3(config)#int e0/0
R3(config-if)#no shut
R3(config-if)#ip add 192.168.1.3 255.255.255.0
R3(config-if)#int e0/1
R3(config-if)#no shut
R3(config-if)#ip add 192.168.2.4 255.255.255.0
R3(config-if)#exit
R3(config-if)#exit
R3(config)#int e0/0
R3(config-if)#vrrp 10 ip 192.168.1.254
R3(config-if)#int e0/1
R3(config-if)#vrrp 20 ip 192.168.2.254
R3(config-if)#vrrp 20 priority 150
R3(config-if)#vrrp 20 preempt
R3(config-if)#exit
|
R2#show vrrp br
Interface
Grp Pri Time Own Pre State Master addr Group addr
Et0/0
10 150 3414 Y Master 192.168.1.2 192.168.1.254
Et0/1
20 100 3609 Y Backup 192.168.2.4 192.168.2.254
|
R3#show vrrp br
Interface
Grp Pri Time Own Pre State Master addr Group addr
Et0/0
10 100 3609 Y Backup 192.168.1.2 192.168.1.254
Et0/1
20 150 3414 Y Master 192.168.2.4 192.168.2.254
|
R2(config)#
track 50 interface e0/1 line-protocol //
全局下定义track
对象
R2(config-track)#interface e0/0
R2(config-if)#
vrrp 10 track 50 decrement 70 //
接口下启用track
R2(config-if)#end
|
R3(config)#
track 60 interface e0/0 line-protocol
R3(config-track)#int e0/1
R3(config-if)#
vrrp 20 track 60 decrement 70
R3(config-if)#end
|
R2(config)#int e0/1
R2(config-if)#shut
R2(config-if)#end
R2#show vrrp br
Interface
Grp Pri Time Own Pre State Master addr Group addr
Et0/0
10 80 3414 Y Backup 192.168.1.3 192.168.1.254
Et0/1
20 100 3609 Y Init 192.168.2.4 192.168.2.254
R3#show vrrp br
Interface
Grp Pri Time Own Pre State Master addr Group addr
Et0/0
10 100 3609 Y Master 192.168.1.3 192.168.1.254
Et0/1
20 150 3414 Y Master 192.168.2.4 192.168.2.254
说明:当e0/1down
掉以后,自动切换到了R3
,现在pc1
到pc2
走R3
,并且R2 vrrp
的优先级自动减少了70.
|
R2(config)#int e0/1
R2(config-if)#no shut
R2(config-if)#end
R2#show vrrp br
Interface
Grp Pri Time Own Pre State Master addr Group addr
Et0/0
10 150 3414 Y Master 192.168.1.2 192.168.1.254
Et0/1
20 100 3609 Y Backup 192.168.2.4 192.168.2.254
R3#show vrrp br
Interface
Grp Pri Time Own Pre State Master addr Group addr
Et0/0
10 100 3609 Y Init 0.0.0.0 192.168.1.254
Et0/1 20 80 3414
Y Backup 192.168.2.3 192.168.2.254
说明:当R2
的接口恢复正常以后,pc1
到pc2
的线路自动切回了R2
,这是因为R2
上面启用了抢占功能。
|