A-A+

华为路由交换VRRP配置的配置方法、实验

2015年11月27日 路由器高级应用 暂无评论 阅读 3 views 次

学习目的:

1、了解网络负载均衡的功能和作用。

2、理解VRRP协议的工作原理。

3、掌握三层交换环境单组VRRP的配置方法。

4、掌握VRRP认证配置方法。

5、掌握VRRP跟踪接口的配置方法。

6、掌握使用VRRP实现负载均衡的配置方法。

拓扑图

场景

你是公司的网络管理员。当前的网络中有两个用户。用R2、R3标注为公司用户。R1使用回环口模拟为Internet服务器。此时网络中有两个网关,为实现冗余。现在使用VRRP来实现冗余。

学习任务

步骤一.基本配置与IP编址

在实验之前,需要关闭部分设备接口,避免影响本次实验。

本次实验需要关闭S1的G0/0/9、G0/0/13和G0/0/14接口。关闭这些接口之后,开始实验配置。

用户网络使用vlan1,S1使用vlan2与R1相连,S2使用vlan3与R1相连,R1配置loopback接口;R2、R3作为客户,配置IP、缺省网关。

路由器R1模拟为广域网,它的回环模拟为广域网中的一台服务器。

  1. [Huawei]sysname R1  
  2. [R1]interface loopback0  
  3. [R1-LoopBack0]ip add 10.0.1.1 24  
  4. [R1-LoopBack0]interface g0/0/1  
  5. [R1-GigabitEthernet0/0/1]ip add 10.0.11.224  
  6.   
  7. [R1-GigabitEthernet0/0/1]desc this portconnect to S1-G0/0/1  
  8. [R1-GigabitEthernet0/0/1]interface g0/0/2  
  9. [R1-GigabitEthernet0/0/2]ip add 10.0.12.224  
  10. [R1-GigabitEthernet0/0/2]desc this portconnect to S2-G0/0/2  
  11. [R1-GigabitEthernet0/0/2]q  

R2是局域网中的一台PC设备,使用网段10.0.123.0/24,网关为10.0.123.1.

R3是局域网中的另一台PC设备,使用网段为10.0.123.0/24,网关为10.0.123.1.

交换机S1配置vlan1、2、3,接口模式为hybird模式。将接口G0/0/10配置为Trunk接口,允许所有vlan通过,G0/0/1配置为access类型接口,属于vlan2,G0/0/2配置为access类型接口,属于vlan1.配置vlanif1,为vlan1提供网关服务,IP地址为10.0.123.2/24;配置vlanif2,作为与R1连接的三层接口,ip地址为10.0.11.1/24.

  1. [Huawei]sysname S1  
  2. [S1]vlan batch 1 to 3  
  3. [S1]interface g0/0/10  
  4. [S1-GigabitEthernet0/0/10]port link-typetrunk  
  5. [S1-GigabitEthernet0/0/10]port trunkallow-pass vlan all  
  6. [S1-GigabitEthernet0/0/10]interface g0/0/1  
  7. [S1-GigabitEthernet0/0/1]port link-typeaccess   
  8. [S1-GigabitEthernet0/0/1]port default vlan2  
  9. [S1-GigabitEthernet0/0/1]interface g0/0/2  
  10. [S1-GigabitEthernet0/0/2]port link-typeaccess  
  11. [S1-GigabitEthernet0/0/2]port default vlan1  
  12. [S1-GigabitEthernet0/0/2]interface vlanif 1  
  13. [S1-Vlanif1]ip add 10.0.123.2 24  
  14. [S1-Vlanif1]interface vlanif 2  
  15. [S1-Vlanif2]ip add 10.0.11.1 24  

交换机S2配置vlan1、2、3.接口默认为hybired模式。将接口G0/0/10配置成trunk接口,允许所有vlan通过,G0/0/2配置为access类型接口,属于vlan3,G0/0/3配置为access类型接口,属于vlan1.配置vlanif1,为vlan1提供网关服务,IP地址为10.0.123.3/24,配置vlanif3,作为与R1连接的三层接口,IP地址为10.0.12.1/24.

  1. [Huawei]sysname S2  
  2. [S2]vlan batch 1 to 3  
  3. [S2]interface g0/0/10  
  4. [S2-GigabitEthernet0/0/10]port link-typetrunk  
  5. [S2-GigabitEthernet0/0/10]port trunkallow-pass vlan all  
  6. [S2-GigabitEthernet0/0/10]interface g0/0/2  
  7. [S2-GigabitEthernet0/0/2]port link-typeaccess  
  8. [S2-GigabitEthernet0/0/2]port default vlan3  
  9. [S2-GigabitEthernet0/0/2]interface g0/0/3   
  10. [S2-GigabitEthernet0/0/3]port link-typeaccess  
  11. [S2-GigabitEthernet0/0/3]port default vlan1  
  12. [S2-GigabitEthernet0/0/3]interface vlanif 1  
  13. [S2-Vlanif1]ip add 10.0.123.3 24  
  14. [S2-Vlanif1]interface vlanif 3  
  15. [S2-Vlanif3]ip add 10.0.12.1 24  

配置完成后,测试直连链路的连通性,在S2上测试其于S1、R1、R2、R3之间的联通行。(使用ping命令测试,加上参数“-c 1”代表一个ping包进行测试。默认连续发送5个)。

  1. [S2]ping -c 1 10.0.12.2  
  2.  PING 10.0.12.2: 56  data bytes,press CTRL_C to break  
  3.    Reply from 10.0.12.2: bytes=56 Sequence=1 ttl=255 time=90 ms  
  4.    
  5.   ---10.0.12.2 ping statistics ---  
  6.     1packet(s) transmitted  
  7.     1packet(s) received  
  8.    0.00% packet loss  
  9.    round-trip min/avg/max = 90/90/90 ms  
  10.    
  11. [S2]ping -c 1 10.0.123.2  
  12.  PING 10.0.123.2: 56  data bytes,press CTRL_C to break   
  13.    Reply from 10.0.123.2: bytes=56 Sequence=1 ttl=255 time=50 ms  
  14.    
  15.   ---10.0.123.2 ping statistics ---  
  16.     1packet(s) transmitted  
  17.     1packet(s) received  
  18.    0.00% packet loss  
  19.    round-trip min/avg/max = 50/50/50 ms  
  20.    
  21. [S2]ping -c 1 10.0.123.4  
  22.  PING 10.0.123.4: 56  data bytes,press CTRL_C to break  
  23.    Reply from 10.0.123.4: bytes=56 Sequence=1 ttl=128 time=70 ms  
  24.    
  25.   ---10.0.123.4 ping statistics ---  
  26.     1packet(s) transmitted  
  27.     1packet(s) received  
  28.    0.00% packet loss  
  29.    round-trip min/avg/max = 70/70/70 ms  
  30.    
  31. [S2]ping -c 1 10.0.123.5  
  32.  PING 10.0.123.5: 56  data bytes,press CTRL_C to break  
  33.    Reply from 10.0.123.5: bytes=56 Sequence=1 ttl=128 time=10 ms  
  34.    
  35.   ---10.0.123.5 ping statistics ---   
  36.     1packet(s) transmitted  
  37.     1packet(s) received  
  38.    0.00% packet loss  
  39.    round-trip min/avg/max = 10/10/10 ms  

步骤二.配置OSPF路由协议,实现s1、S2、R1之间的路由联通

  1. [S1]ospf 1.  
  2. [S1-ospf-1]area 0  
  3. [S1-ospf-1-area-0.0.0.0]network 10.0.0.00.255.255.255  
  4. [S1-ospf-1-area-0.0.0.0]q  
  5. [S1-ospf-1]silent-interface vlanif 1  
  6.    
  7. [S2]ospf 1  
  8. [S2-ospf-1]area 0  
  9. [S2-ospf-1-area-0.0.0.0]network 10.0.0.00.255.255.255  
  10. [S2-ospf-1-area-0.0.0.0]q  
  11. [S2-ospf-1]silent-interface vlanif 1  
  12.    
  13. [R1]ospf 1  
  14. [R1-ospf-1]area 0  
  15. [R1-ospf-1-area-0.0.0.0]network 10.0.0.00.255.255.255  

配置完成后,稍等片刻,等待网络收敛后,测试网络的连通性。

  1. [S2]ping -c 1 10.0.11.1  
  2.  PING 10.0.11.1: 56  data bytes,press CTRL_C to break  
  3.    Reply from 10.0.11.1: bytes=56 Sequence=1 ttl=254 time=60 ms  
  4.    
  5.   ---10.0.11.1 ping statistics ---   
  6.     1packet(s) transmitted  
  7.     1packet(s) received  
  8.    0.00% packet loss  
  9.    round-trip min/avg/max = 60/60/60 ms  
  10. [S2]ping -c 1 10.0.1.1  
  11.  PING 10.0.1.1: 56  data bytes,press CTRL_C to break  
  12.    Reply from 10.0.1.1: bytes=56 Sequence=1 ttl=255 time=50 ms  
  13.    
  14.   ---10.0.1.1 ping statistics ---  
  15.     1packet(s) transmitted  
  16.     1packet(s) received  
  17.    0.00% packet loss  
  18.     round-tripmin/avg/max = 50/50/50 ms  
  19.    
  20. [S2]ping -c 1 10.0.12.2  
  21.  PING 10.0.12.2: 56  data bytes,press CTRL_C to break  
  22.    Reply from 10.0.12.2: bytes=56 Sequence=1 ttl=255 time=60 ms  
  23.    
  24.   ---10.0.12.2 ping statistics ---  
  25.     1packet(s) transmitted  
  26.     1packet(s) received  
  27.    0.00% packet loss  
  28.    round-trip min/avg/max = 60/60/60 ms   

步骤三.配置VRRP,实现网关冗余

S1配置VRRP,使用VRRP组1,默认优先级为100,实验中定义为105.

  1. [S1]interface vlanif 1  
  2. [S1-Vlanif1]vrrp vrid 1 virtual-ip10.0.123.1  
  3. [S1-Vlanif1]vrrp vrid 1 priority 105  
  4.    
  5. [S2]interface vlanif 1  
  6. [S2-Vlanif1]vrrp vri    
  7. [S2-Vlanif1]vrrp vrid 1 vir  
  8. [S2-Vlanif1]vrrp vrid 1 virtual-ip10.0.123.1  

配置完成后,在R2和R3上测试他们与模拟的Internet服务器之间的通讯是否正常。

在S1上查看VRRP当前的状态信息。

  1. [S1]disp vrrp  
  2.  Vlanif1 | Virtual Router 1  
  3.     State : Master  
  4.    Virtual IP : 10.0.123.1  
  5.    Master IP : 10.0.123.2  
  6.    PriorityRun : 105  
  7.    PriorityConfig : 105  
  8.    MasterPriority : 105   
  9.    Preempt : YES   Delay Time : 0 s  
  10.    TimerRun : 1 s  
  11.    TimerConfig : 1 s  
  12.    Auth type : NONE  
  13.    Virtual MAC : 0000-5e00-0101  
  14.    Check TTL : YES  
  15.    Config type : normal-vrrp  
  16.    Create time : 2014-07-03 11:58:33 UTC-08:00  
  17. Last change time: 2014-07-03 11:58:37 UTC-08:00  

当前R2与R3都是通过S1将数据包发送至internet的。关闭S1的vlanif 1接口,然后测试网络是否正常切换。

[S1]interface vlanif 1
[S1-Vlanif1]shutdown

在R2与R3上测试他们与模拟Internet服务器之间的通讯是否正常。

此时相当于S1设备停止工作,查看S1与S2的VRRP状态。

  1. [S1]disp vrrp  
  2.  Vlanif1 | Virtual Router 1  
  3.     State : Initialize  
  4.    Virtual IP : 10.0.123.1   
  5.    Master IP : 0.0.0.0  
  6.    PriorityRun : 105  
  7.    PriorityConfig : 105  
  8.    MasterPriority : 0  
  9.    Preempt : YES   Delay Time : 0 s  
  10.    TimerRun : 1 s  
  11.    TimerConfig : 1 s  
  12.    Auth type : NONE  
  13.    Virtual MAC : 0000-5e00-0101  
  14.    Check TTL : YES  
  15.    Config type : normal-vrrp  
  16.    Create time : 2014-07-03 11:58:33 UTC-08:00  
  17. Last change time: 2014-07-03 12:09:28 UTC-08:00  
  18.    
  19. <S2>dispvrrp  
  20.   Vlanif1 | Virtual Router 1  
  21.     State : Master  
  22.     Virtual IP : 10.0.123.1  
  23.     Master IP : 10.0.123.2  
  24.     PriorityRun : 100  
  25.     PriorityConfig : 100  
  26.     MasterPriority : 100  
  27.     Preempt : YES   Delay Time : 0 s  
  28.     TimerRun : 1 s   
  29.     TimerConfig : 1 s  
  30.     Auth type : NONE  
  31.     Virtual MAC : 0000-5e00-0101  
  32.     Check TTL : YES  
  33.     Config type : normal-vrrp  
  34.     Create time : 2014-07-03 12:01:18 UTC-08:00  
  35.     Last change time : 2014-07-03 12:01:21UTC-08:00  

步骤四.跟踪接口状态

重新打开S1的vlanif1接口,并配置S1、S2踪它们的G0/0/1、G0/0/2接口。

[S1]interfacevlanif 1

[S1-Vlanif1]undoshutdown

查看S1的vrrp状态。

  1. [S1]displ vrrp  
  2.   Vlanif1 | Virtual Router 1  
  3.     State : Master  
  4.     Virtual IP : 10.0.123.1  
  5.     Master IP : 10.0.123.2  
  6.     PriorityRun : 105  
  7.     PriorityConfig : 105  
  8.     MasterPriority : 105  
  9.     Preempt : YES   Delay Time : 0 s   
  10.     TimerRun : 1 s  
  11.     TimerConfig : 1 s  
  12.     Auth type : NONE  
  13.     Virtual MAC : 0000-5e00-0101  
  14.     Check TTL : YES  
  15.     Config type : normal-vrrp  
  16.     Create time : 2014-07-03 11:58:33 UTC-08:00  
  17.     Last change time : 2014-07-03 12:21:05UTC-08:00  

此时R2与R3通过S1发送数据给internet。如果关闭S1的G0/0/1接口,或关闭R1的G0/0/1接口,网络将无法自动切换到通过S2发送数据给internet。

关闭S1的G0/0/1接口

  1. [S1]interfaceg0/0/1  
  2. [S1-GigabitEthernet0/0/1]shutdown  
  3. [S1]dis vrrp brief  
  4. VRID  State       Interface                Type     Virtual IP      
  5. ----------------------------------------------------------------   
  6. 1     Master       Vlanif1                  Normal   10.0.123.1      
  7. ----------------------------------------------------------------  
  8. Total:1     Master:1     Backup:0     Non-active:0  

注:使用brief参数可以显示简略信息。

测试R2与internet的连通性。

显示无法正常通信

重新打开S1的G0/0/1接口

[S1]interfaceg0/0/1
[S1-GigabitEthernet0/0/1]undoshutdown

S1和S2上配置VRRP的接口跟踪,定义跟踪G0/0/1接口,如果接口被关闭,则由此岸及降低10.这样的情况下,S2将抢占S1的VRRP主角色

[S1]interfacevlanif 1
[S1-Vlanif1]vrrpvrid 1 track interface g0/0/1 reduced 10

[S2]interfacevlanif 1
[S2-Vlanif1]vrrpvrid 1 track interface g0/0/2 reduced 10

此时,测试网络的连通性。

网络正常时,R2可以与internet服务器通信。

关闭S1的G0/0/1接口

[S1]interfaceg0/0/1

[S1-GigabitEthernet0/0/1]shutdown

测试R2与internet服务器之间的连通性。

通讯依然正常,查看S1的vrrp状态。

  1. [S1]dis vrrp  
  2.   Vlanif1 | Virtual Router 1  
  3.     State : Backup  
  4.     Virtual IP : 10.0.123.1  
  5.     Master IP : 10.0.123.3  
  6.     PriorityRun : 95  
  7.     PriorityConfig : 105  
  8.     MasterPriority : 100  
  9.     Preempt : YES   Delay Time : 0 s  
  10.     TimerRun : 1 s  
  11.     TimerConfig : 1 s  
  12.     Auth type : NONE  
  13.     Virtual MAC : 0000-5e00-0101  
  14.     Check TTL : YES  
  15.     Config type : normal-vrrp  
  16.     Track IF :GigabitEthernet0/0/1   Priority reduced :10  
  17.     IF state : DOWN  
  18.     Create time : 2014-07-03 11:58:33 UTC-08:00   
  19.     Last change time : 2014-07-03 14:58:38UTC-08:00  
标签:

给我留言