收藏本站 | RSS订阅三块钱的博客
你现在的位置:网站首页 - 首页 - 华为交换机配置VRRP主备备份示例
11月07日

华为交换机配置VRRP主备备份示例

作者 : 三块钱 | 分类 : 首页 | 超过 人围观 | 已有 0 人留下了看法

组网需求

图1所示,HostA通过Switch双归属到SwitchA和SwitchB。为保证用户的各种业务在网络传输中不中断,需在SwitchA和SwitchB上配置VRRP主备备份功能。
  • 正常情况下,主机以SwitchA为默认网关接入Internet,当SwitchA故障时,SwitchB接替SwitchA作为网关继续进行工作,实现网关的冗余备份。

  • SwitchA故障恢复后,其延时20秒通过抢占的方式重新成为Master,承担数据传输。

 说明:

请确保该场景下互联接口的STP处于未使能状态。同时将互连接口退出VLAN1,避免形成环路。因为在使能STP的环形网络中,如果用交换机的VLANIF接口构建三层网络,会导致某个端口被阻塞,从而导致三层业务不能正常运行。

图1 配置VRRP主备备份组网图 

设备

接口

对应的Vlanif

IP地址

SwitchA

GE1/0/1

VLANIF300

192.168.1.1/24

GE1/0/2

VLANIF100

10.1.1.1/24

SwitchB

GE1/0/1

VLANIF200

192.168.2.1/24

GE1/0/2

VLANIF100

10.1.1.2/24

SwitchC

GE1/0/1

VLANIF300

192.168.1.2/24

GE1/0/2

VLANIF200

192.168.2.2/24

GE1/0/3

VLANIF400

172.16.1.1/24


配置思路

采用VRRP主备备份实现网关冗余备份,配置思路如下:

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

  2. SwitchA和SwitchB上配置VRRP备份组。其中,SwitchA上配置较高优先级和20秒抢占延时,作为Master设备承担流量转发;SwitchB上配置较低优先级,作为备用交换机,实现网关冗余备份。


操作步骤

  1. 配置设备间的网络互连


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

    <HUAWEI> system-view
  2. [HUAWEI] sysname SwitchA
  3. [SwitchA] vlan batch 100 300
  4. [SwitchA] interface gigabitethernet 1/0/1
  5. [SwitchA-GigabitEthernet1/0/1] port link-type hybrid
  6. [SwitchA-GigabitEthernet1/0/1] port hybrid pvid vlan 300
  7. [SwitchA-GigabitEthernet1/0/1] port hybrid untagged vlan 300
  8. [SwitchA-GigabitEthernet1/0/1] quit
  9. [SwitchA] interface gigabitethernet 1/0/2
  10. [SwitchA-GigabitEthernet1/0/2] port link-type hybrid
  11. [SwitchA-GigabitEthernet1/0/2] port hybrid pvid vlan 100
  12. [SwitchA-GigabitEthernet1/0/2] port hybrid untagged vlan 100
  13. [SwitchA-GigabitEthernet1/0/2] quit[SwitchA] interface vlanif 100
  14. [SwitchA-Vlanif100] ip address 10.1.1.1 24
  15. [SwitchA-Vlanif100] quit
  16. [SwitchA] interface vlanif 300
  17. [SwitchA-Vlanif300] ip address 192.168.1.1 24
  18. [SwitchA-Vlanif300] quit

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

    <HUAWEI> system-view
  19. [HUAWEI] sysname Switch
  20. [Switch] vlan 100
  21. [Switch-vlan100] quit
  22. [Switch] interface gigabitethernet 1/0/1
  23. [Switch-GigabitEthernet1/0/1] port link-type hybrid
  24. [Switch-GigabitEthernet1/0/1] port hybrid pvid vlan 100
  25. [Switch-GigabitEthernet1/0/1] port hybrid untagged vlan 100
  26. [Switch-GigabitEthernet1/0/1] quit[Switch] interface gigabitethernet 1/0/2
  27. [Switch-GigabitEthernet1/0/2] port link-type hybrid
  28. [Switch-GigabitEthernet1/0/2] port hybrid pvid vlan 100
  29. [Switch-GigabitEthernet1/0/2] port hybrid untagged vlan 100
  30. [Switch-GigabitEthernet1/0/2] quit

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

    [SwitchA] ospf 1[SwitchA-ospf-1] area 0
  31. [SwitchA-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
  32. [SwitchA-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255
  33. [SwitchA-ospf-1-area-0.0.0.0] quit[SwitchA-ospf-1] quit


  34. 配置VRRP备份组


    # 在SwitchA上创建VRRP备份组1,配置SwitchA在该备份组中的优先级为120,并配置抢占时间为20秒。

    [SwitchA] interface vlanif 100
  35. [SwitchA-Vlanif100] vrrp vrid 1 virtual-ip 10.1.1.111
  36. [SwitchA-Vlanif100] vrrp vrid 1 priority 120
  37. [SwitchA-Vlanif100] vrrp vrid 1 preempt-mode timer delay 20
  38. [SwitchA-Vlanif100] quit

    # 在SwitchB上创建VRRP备份组1,其在该备份组中的优先级为缺省值100。

    [SwitchB] interface vlanif 100
  39. [SwitchB-Vlanif100] vrrp vrid 1 virtual-ip 10.1.1.111
  40. [SwitchB-Vlanif100] quit


  41. 验证配置结果


    # 完成上述配置以后,在SwitchA和SwitchB上分别执行display vrrp命令,可以看到SwitchA在备份组中的状态为Master,SwitchB在备份组中的状态为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
    [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

    # 在SwitchA和SwitchB上执行display ip routing-table命令,SwitchA上可以看到路由表中有一条目的地址为虚拟IP地址的直连路由,而SwitchB上该路由为OSPF路由。SwitchA和SwitchB上的显示信息如下。

    [SwitchA] display ip routing-tableRoute Flags: R - relay, D - download to fib, T - to vpn-instance------------------------------------------------------------------------------  
    Routing Tables: Public                                                          
             Destinations : 9       Routes : 10                                    
                                                                                    
    Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface      
                                                                                    
         10.1.1.0/24    Direct   0     0         D      10.1.1.1        Vlanif100
         10.1.1.1/32    Direct   0     0         D      127.0.0.1       Vlanif100 10.1.1.111/32    Direct  0     0     D   127.0.0.1     Vlanif100
         127.0.0.0/8    Direct   0    0          D      127.0.0.1       InLoopBack0
        127.0.0.1/32    Direct   0    0          D      127.0.0.1       InLoopBack0
       172.16.1.0/24    OSPF     10   2          D      192.168.1.2     Vlanif300
      192.168.1.0/24    Direct   0    0          D      192.168.1.1     Vlanif300
      192.168.1.1/32    Direct   0    0          D      127.0.0.1       Vlanif300
      192.168.2.0/24    OSPF     10   2          D      10.1.1.2        Vlanif100
                        OSPF     10   2          D      192.168.1.2     Vlanif300
    [SwitchB] display ip routing-tableRoute Flags: R - relay, D - download to fib, T - to vpn-instance----------------
  42. Routing Tables: Public                                                          
             Destinations : 9       Routes : 10                                    
                                                                                    
    Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface      
                                                                                    
         10.1.1.0/24    Direct   0     0         D     10.1.1.2        Vlanif100
         10.1.1.2/32    Direct   0     0         D     127.0.0.1       Vlanif100 10.1.1.111/32    OSPF    10    2   D     10.1.1.1      Vlanif100
         127.0.0.0/8    Direct   0     0         D     127.0.0.1       InLoopBack0
        127.0.0.1/32    Direct   0     0         D     127.0.0.1       InLoopBack0
       172.16.1.0/24    OSPF     10    2         D     192.168.2.2     Vlanif200
      192.168.1.0/24    OSPF     10    2         D     10.1.1.1        Vlanif100
                        OSPF     10    2         D     192.168.2.2     Vlanif200
      192.168.2.0/24    Direct   0     0         D     192.168.2.1     Vlanif200
      192.168.2.1/32    Direct   0     0         D     127.0.0.1       Vlanif200

    # 在SwitchA的接口GE1/0/2上执行shutdown命令,模拟SwitchA出现故障。

    [SwitchA] interface gigabitethernet 1/0/2
  43. [SwitchA-GigabitEthernet1/0/2] shutdown
  44. [SwitchA-GigabitEthernet1/0/2] quit

    # 在SwitchB上执行display vrrp命令查看VRRP状态信息,可以看到SwitchB的状态是Master。

    [SwitchB] display vrrp
      Vlanif100 | Virtual Router 1    State : Master
        Virtual IP : 10.1.1.111
        Master IP : 10.1.1.2
        PriorityRun : 100
        PriorityConfig : 100                                                        
        MasterPriority : 100                                                        
        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:18:40

    # 在SwitchA的接口GE1/0/2上执行undo shutdown命令。

    [SwitchA] interface gigabitethernet 1/0/2
  45. [SwitchA-GigabitEthernet1/0/2] undo shutdown
  46. [SwitchA-GigabitEthernet1/0/2] quit

    # 等待20秒后,在SwitchA上执行display vrrp命令查看VRRP状态信息,可以看到SwitchA的状态恢复成Master。

    [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:20:56



配置文件

  • 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
    #
    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
    #
    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


« 上一篇下一篇 »

已有 0 条评论了

发表评论

必填

选填

选填

必填,不填不让过哦,嘻嘻。

记住我,下次回复时不用重新输入个人信息