利用VRRP实现网络的冗余与负载

    我们知道HSRP协议是cisco公司的私有协议,只能在cisco路由器上实现,当然别的厂商的路由器可以通过VRRP协议来实现,VRRPHSRP协议很相似,其工作原理都一样,但是VRRP是公有协议。下面再来分析一下各网络设备厂商都支持的虚拟路由冗余协议:VRRP (Virtual Router Redundancy Protocol )
 
一、拓扑图:
 
 

二、配置及说明:
1R1的配置:
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 (设置 VRRP1的优先级为 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
 
2R2的配置:
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
 
3、配置 PC1PC2指向各自的网关,以实现冗余和负载:
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
 
 
三、验证实验效果:
1、查看一下 R1R2VRRP全局信息:
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
2、查看一下 R1R2VRRP的摘要信息:
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
3、将 R1f0/0 shutdown 之后,在 PC1traceroute:
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
4、再一次查看 R1R2vrrp摘要信息:
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
 
四、总结: VRRP 协议的工作原理跟 HSRP 基本一样,配置的时候注意一下在全局模式下创建一个事件号,然后在 track 的时候调用这个跟踪事件号。 VRRP 协议是一个公用的标准协议,各厂商的设备都支持。其同样可以实现网络的冗余与负载。
 

 

你可能感兴趣的:(网络,负载,冗余,休闲,vrrp)