如何通过VRRP配置,使两台路由器互为热备份,实现流量均分,写出大概步骤

如题所述

  我给你个负载分担的例子

  如下图所示,HostA和HostC通过Switch双归属到SwitchA和SwitchB。为减轻SwitchA上数据流量的承载压力,HostA以SwitchA为默认网关接入Internet,SwitchB作为备份网关;HostC以SwitchB为默认网关接入Internet,SwitchA作为备份网关,以实现流量的负载均衡。

  配置VRRP负载分担组网图 

  

  配置思路

  采用VRRP负载分担实现流量的负载均衡,配置思路如下:

  配置各设备接口IP地址及路由协议,使各设备间网络层连通。

  在SwitchA和SwitchB上创建VRRP备份组1和VRRP备份组2,在备份组1中,配置SwitchA为Master设备,SwitchB为Backup设备;在备份组2中,配置SwitchB为Master设备,SwitchA为Backup设备,实现流量的负载均衡。


  操作步骤

  配置设备间的网络互连

  # 配置设备各接口的IP地址,以SwitchA为例。SwitchB和SwitchC的配置与SwitchA类似,详见配置文件。

  <HUAWEI> system-view
[HUAWEI] sysname SwitchA
[SwitchA] vlan batch 100 300
[SwitchA] interface gigabitethernet 1/0/1
[SwitchA-GigabitEthernet1/0/1] port link-type hybrid
[SwitchA-GigabitEthernet1/0/1] port hybrid pvid vlan 300
[SwitchA-GigabitEthernet1/0/1] port hybrid untagged vlan 300
[SwitchA-GigabitEthernet1/0/1] quit
[SwitchA] interface gigabitethernet 1/0/2
[SwitchA-GigabitEthernet1/0/2] port link-type hybrid
[SwitchA-GigabitEthernet1/0/2] port hybrid pvid vlan 100
[SwitchA-GigabitEthernet1/0/2] port hybrid untagged vlan 100
[SwitchA-GigabitEthernet1/0/2] quit
[SwitchA] interface vlanif 100
[SwitchA-Vlanif100] ip address 10.1.1.1 24
[SwitchA-Vlanif100] quit
[SwitchA] interface vlanif 300
[SwitchA-Vlanif300] ip address 192.168.1.1 24
[SwitchA-Vlanif300] quit

  # 配置Switch的二层转发功能。

  <HUAWEI> system-view
[HUAWEI] sysname Switch
[Switch] vlan 100
[Switch-vlan100] quit
[Switch] interface gigabitethernet 1/0/1
[Switch-GigabitEthernet1/0/1] port link-type hybrid
[Switch-GigabitEthernet1/0/1] port hybrid pvid vlan 100
[Switch-GigabitEthernet1/0/1] port hybrid untagged vlan 100
[Switch-GigabitEthernet1/0/1] quit
[Switch] interface gigabitethernet 1/0/2
[Switch-GigabitEthernet1/0/2] port link-type hybrid
[Switch-GigabitEthernet1/0/2] port hybrid pvid vlan 100
[Switch-GigabitEthernet1/0/2] port hybrid untagged vlan 100
[Switch-GigabitEthernet1/0/2] quit

  # 配置SwitchA、SwitchB和SwitchC间采用OSPF协议进行互连。以SwitchA为例,SwitchB和SwitchC的配置与SwitchA类似,详见配置文件。

  [SwitchA] ospf 1
[SwitchA-ospf-1] area 0
[SwitchA-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
[SwitchA-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255
[SwitchA-ospf-1-area-0.0.0.0] quit
[SwitchA-ospf-1] quit


  配置VRRP备份组

  # 在SwitchA和SwitchB上创建VRRP备份组1,配置SwitchA的优先级为120,抢占延时为20秒,作为Master设备;SwitchB的优先级为缺省值,作为Backup设备。

  [SwitchA] interface vlanif 100
[SwitchA-Vlanif100] vrrp vrid 1 virtual-ip 10.1.1.111
[SwitchA-Vlanif100] vrrp vrid 1 priority 120
[SwitchA-Vlanif100] vrrp vrid 1 preempt-mode timer delay 20
[SwitchA-Vlanif100] quit
[SwitchB] interface vlanif 100
[SwitchB-Vlanif100] vrrp vrid 1 virtual-ip 10.1.1.111
[SwitchB-Vlanif100] quit

  # 在SwitchA和SwitchB上创建VRRP备份组2,配置SwitchB的优先级为120,抢占延时为20秒,作为Master设备;SwitchA的优先级为缺省值,作为Backup设备。

  [SwitchB] interface vlanif 100
[SwitchB-Vlanif100] vrrp vrid 2 virtual-ip 10.1.1.112
[SwitchB-Vlanif100] vrrp vrid 2 priority 120
[SwitchB-Vlanif100] vrrp vrid 2 preempt-mode timer delay 20
[SwitchB-Vlanif100] quit
[SwitchA] interface vlanif 100
[SwitchA-Vlanif100] vrrp vrid 2 virtual-ip 10.1.1.112
[SwitchA-Vlanif100] quit


  验证配置结果

  # 完成上述配置后,在SwitchA上执行display vrrp命令,可以看到SwitchA在备份组1中作为Master设备,在备份组2中作为Backup设备。

  [SwitchA] display vrrp
 Vlanif100 | Virtual Router 1
   State : Master
   Virtual IP : 10.1.1.111
   Master IP : 10.1.1.1
   PriorityRun : 120
   PriorityConfig : 120                                                        
   MasterPriority : 120                                                        
   Preempt : YES   Delay Time : 20 s
   TimerRun : 1 s
   TimerConfig : 1 s
   Auth type : NONE                                                            
   Virtual MAC : 0000-5e00-0101                                                
   Check TTL : YES                                                            
   Config type : normal-vrrp                                                  
   Backup-forward : disabled
   Create time : 2012-01-12 20:15:46
   Last change time : 2012-01-12 20:15:46

 Vlanif100 | Virtual Router 2
   State : Backup
   Virtual IP : 10.1.1.112
   Master IP : 10.1.1.2
   PriorityRun : 100
   PriorityConfig : 100                                                        
   MasterPriority : 120                                                        
   Preempt : YES   Delay Time : 0 s
   TimerRun : 1 s
   TimerConfig : 1 s
   Auth type : NONE                                                            
   Virtual MAC : 0000-5e00-0102                                                
   Check TTL : YES                                                            
   Config type : normal-vrrp                                                  
   Backup-forward : disabled
   Create time : 2012-01-12 20:15:46
   Last change time : 2012-01-12 20:15:46

  # 在SwitchB上执行display vrrp命令,可以看到SwitchB在备份组1中作为Backup设备,在备份组2中作为Master设备。

  [SwitchB] display vrrp
 Vlanif100 | Virtual Router 1
   State : Backup
   Virtual IP : 10.1.1.111
   Master IP : 10.1.1.1
   PriorityRun : 100
   PriorityConfig : 100                                                        
   MasterPriority : 120                                                        
   Preempt : YES   Delay Time : 0 s
   TimerRun : 1 s
   TimerConfig : 1 s
   Auth type : NONE                                                            
   Virtual MAC : 0000-5e00-0101                                                
   Check TTL : YES                                                            
   Config type : normal-vrrp                                                  
   Backup-forward : disabled
   Create time : 2012-01-12 20:15:46
   Last change time : 2012-01-12 20:15:46

 Vlanif100 | Virtual Router 2
   State : Master
   Virtual IP : 10.1.1.112
   Master IP : 10.1.1.2
   PriorityRun : 120
   PriorityConfig : 120                                                        
   MasterPriority : 120                                                        
   Preempt : YES   Delay Time : 20 s
   TimerRun : 1 s
   TimerConfig : 1 s
   Auth type : NONE                                                            
   Virtual MAC : 0000-5e00-0102                                                
   Check TTL : YES                                                            
   Config type : normal-vrrp                                                  
   Backup-forward : disabled
   Create time : 2012-01-12 20:15:46
   Last change time : 2012-01-12 20:15:46


  配置文件

  SwitchA的配置文件

  #
sysname SwitchA
#
vlan batch 100 300
#
interface Vlanif100
ip address 10.1.1.1 255.255.255.0
vrrp vrid 1 virtual-ip 10.1.1.111
vrrp vrid 1 priority 120
vrrp vrid 1 preempt-mode timer delay 20
vrrp vrid 2 virtual-ip 10.1.1.112
#
interface Vlanif300
ip address 192.168.1.1 255.255.255.0
#
interface GigabitEthernet1/0/1
port link-type hybrid
port hybrid pvid vlan 300
port hybrid untagged vlan 300
#
interface GigabitEthernet1/0/2
port link-type hybrid
port hybrid pvid vlan 100
port hybrid untagged vlan 100
#
ospf 1
area 0.0.0.0
 network 10.1.1.0 0.0.0.255
 network 192.168.1.0 0.0.0.255
#
return


  SwitchB的配置文件

  #
sysname SwitchB
#
vlan batch 100 200
#
interface Vlanif100
ip address 10.1.1.2 255.255.255.0
vrrp vrid 1 virtual-ip 10.1.1.111
vrrp vrid 2 virtual-ip 10.1.1.112
vrrp vrid 2 priority 120
vrrp vrid 2 preempt-mode timer delay 20
#
interface Vlanif200
ip address 192.168.2.1 255.255.255.0
#
interface GigabitEthernet1/0/1
port link-type hybrid
port hybrid pvid vlan 200
port hybrid untagged vlan 200
#
interface GigabitEthernet1/0/2
port link-type hybrid
port hybrid pvid vlan 100
port hybrid untagged vlan 100
#
ospf 1
area 0.0.0.0
 network 10.1.1.0 0.0.0.255
 network 192.168.2.0 0.0.0.255
#
return


  SwitchC的配置文件

  #
sysname SwitchC
#
vlan batch 200 300 400
#
interface Vlanif200
ip address 192.168.2.2 255.255.255.0
#
interface Vlanif300
ip address 192.168.1.2 255.255.255.0
#
interface Vlanif400
ip address 172.16.1.1 255.255.255.0
#
interface GigabitEthernet1/0/1
port link-type hybrid
port hybrid pvid vlan 300
port hybrid untagged vlan 300
#
interface GigabitEthernet1/0/2
port link-type hybrid
port hybrid pvid vlan 200
port hybrid untagged vlan 200
#
interface GigabitEthernet1/0/3
port link-type hybrid
port hybrid pvid vlan 400
port hybrid untagged vlan 400
#
ospf 1
area 0.0.0.0
 network 172.16.1.0 0.0.0.255
 network 192.168.1.0 0.0.0.255
 network 192.168.2.0 0.0.0.255
#
return

  Switch的配置文件

  #
sysname Switch
#
vlan batch 100
#
interface GigabitEthernet1/0/1
port link-type hybrid
port hybrid pvid vlan 100
port hybrid untagged vlan 100
#
interface GigabitEthernet1/0/2
port link-type hybrid
port hybrid pvid vlan 100
port hybrid untagged vlan 100
#
return

更多的例子你也可以参考 重庆网管 博客

温馨提示:答案为网友推荐,仅供参考
相似回答