VRRP可以监视上行端口的状态,当设备感知上行端口或者链路发生故障时,可以主动的降低VRRP的优先级,从而保证上行链路正常的backup设备能够通过选举切换成Master状态,指导报文转发。

        接入交换机为SW1,核心交换机为SW2和SW3,SW2与SW3做一个VRRP路由冗余。除此之外PC1能够正常的访问到Inetrnet,拓扑如下:

         1.PC1配置地址:192.168.10.1 网关:192.168.10.254

         2.配置接入交换机SW1

        ①改名字,取消提示消息并配置g0/0/3接口,考虑到PC1要与vlan10的网络互通,因此将PC1的接口划分到VLAN 10 中。

更改名字为:[Huawei]sysname acsw
取消提示消息:[acsw]undo info-center enable
配置接口g0/0/3:
[acsw-vlan10]vlan 10
[acsw-vlan100]quit
[acsw]interface g0/0/3
[acsw-GigabitEthernet0/0/3]port link-type access
[acsw-GigabitEthernet0/0/3]port default vlan 10

        ②配置上行接口。配置接入交换机acsw的上行接口,接入交换机与核心交换机相连,故配置成trunk:

[acsw]interface g0/0/1
[acsw-GigabitEthernet0/0/1]port link-type trunk
[acsw-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[acsw-GigabitEthernet0/0/1]quit
[acsw]interface g0/0/2
[acsw-GigabitEthernet0/0/2]port link-type trunk
[acsw-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[acsw-GigabitEthernet0/0/2]

         3.配置核心交换机SW2

        ①配置csw1。下行trunk,上行配置access,并配置一个vlanif100从而实现与上行接口网络互连。

配置下行接口g0/0/1
[csw1]interface g0/0/1
[csw1-GigabitEthernet0/0/1]port link-type trunk
[csw1-GigabitEthernet0/0/1]port trunk allow-pass vlan all

配置下行接口g0/0/3
[csw1-GigabitEthernet0/0/2]interface g0/0/3
[csw1-GigabitEthernet0/0/3]port link-type trunk
[csw1-GigabitEthernet0/0/3]port trunk allow-pass vlan all

创建vlan,配置接口g0/0/2并将上行端口放入vlan 100中:
[csw1]vlan 10
[csw1-vlan10]vlan 100
[csw1-vlan100]quit
[csw1]interface g0/0/2
[csw1-GigabitEthernet0/0/2]port link-type access
[csw1-GigabitEthernet0/0/2]port default vlan 100
[csw1-GigabitEthernet0/0/2]quit

        ②配置csw1的三层接口:

[csw1]int vlan10
[csw1-Vlanif10]ip address 192.168.10.252 24
[csw1-Vlanif10]quit
[csw1]int vlan 100
[csw1-Vlanif100]ip address 192.168.100.1 30

        4.配置核心交换机SW3:与SW2同理

配置接口g0/0/1
[csw2]interface g0/0/1
[csw2-GigabitEthernet0/0/1]port link-type trunk
[csw2-GigabitEthernet0/0/1]port trunk allow-pass vlan all

配置接口g0/0/3
[csw2-GigabitEthernet0/0/1]interface g0/0/3
[csw2-GigabitEthernet0/0/3]port link-type trunk
[csw2-GigabitEthernet0/0/3]port trunk allow-pass vlan all
[csw2-GigabitEthernet0/0/3]quit

配置接口g0/0/2
[csw2]vlan 10
[csw2-vlan10]vlan 200
[csw2-vlan200]quit
[csw2]interface g0/0/2
[csw2-GigabitEthernet0/0/2]port link-type access
[csw2-GigabitEthernet0/0/2]port default vlan 200
[csw2-GigabitEthernet0/0/2]quit

配置三层接口:
[csw2]interface vlanif10
[csw2-Vlanif10]ip address 192.168.10.253 24
[csw2-Vlanif10]quit
[csw2]int vlanif100
Error: The VLAN does not exist.
[csw2]int vlanif200
[csw2-Vlanif200]ip address 192.168.200.1 30

        5.使用两台核心交换机ping测试是否连通,使用PC1ping两台核心交换机是否连通,证明没问题。

        6.VRRP配置

配置csw1为master,优先级为120,抢占延迟为20s
[csw1]int vlanif 10
[csw1-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
[csw1-Vlanif10]vrrp vrid 10 priority 120
[csw1-Vlanif10]vrrp vrid 10 preempt-mode timer delay 20
[csw1-Vlanif10]quit

配置csw2的backup,默认优先级
[csw2]interface vlanif 10
[csw2-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254

        7.查看vrrp配置,可以看到csw1是master而csw2是backup

[csw1]display vrrp
  Vlanif10 | Virtual Router 10
    State : Master
    Virtual IP : 192.168.10.254
    Master IP : 192.168.10.252
    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-010a
    Check TTL : YES
    Config type : normal-vrrp
    Create time : 2023-05-06 15:13:45 UTC-08:00
    Last change time : 2023-05-06 15:13:48 UTC-08:00
[csw2]display vrrp
  Vlanif10 | Virtual Router 10
    State : Backup
    Virtual IP : 192.168.10.254
    Master IP : 192.168.10.252
    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-010a
    Check TTL : YES
    Config type : normal-vrrp
    Create time : 2023-05-06 15:16:30 UTC-08:00
    Last change time : 2023-05-06 15:16:30 UTC-08:00

        8.配置路由器R1

<Huawei>system-view
[Huawei]sysname R1
[R1]interface g0/0/1
[R1-GigabitEthernet0/0/1]ip address 192.168.100.2 30
[R1-GigabitEthernet0/0/1]quit
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]ip address 100.1.1.2 30
[R1-GigabitEthernet0/0/0]interface g2/0/0
[R1-GigabitEthernet2/0/0]ip address 192.168.200.2 30
[R1-GigabitEthernet2/0/0]

        9.配置路由器R2

<Huawei>system-view
[R2]sysname Internet
[Internet]interface g0/0/0
[Internet-GigabitEthernet0/0/0]ip address 100.1.1.1 30

        10.配置静态路由
        在PC1ping 路由器100.1.1.1,无法ping通,抓包发现网络还没有送出去,所以要在核心交换机配置默认路由指向出口,把网络送出去(不知道怎么送出去的时候);在三层交换机上配置默认路由指向下一条,确保到目的地有路由;分别在csw1和csw2上配置:

<csw1>system-view
[csw1]ip route-static 0.0.0.0 0.0.0.0 192.168.100.2
<csw2>system-view
[csw2]ip route-static 0.0.0.0 0.0.0.0 192.168.200.2

      配置以上静态路由,使用PC1继续ping 100.1.1.1,还是没有ping通,我们通过抓包进行分析,ping 将数据包送出去了,但是并没有回来。

          11.配置回程路由
         接着我们在R1上使用 display ip routing-table命令,可以发现,R1路由并没有PC1的网络,即路由R1没有192.168.10.0网段的路由,因此我们要在R1上配置回程的静态路由。(这样就可以访问到外网了)

[R1]ip route-static 192.168.10.0(PC1) 24 192.168.100.1
[R1]ip route-static 192.168.10.0 (PC1)24 192.168.200.1

        12.在pc1上用tracert命令跟踪路由。

        13.调csw1的优先级。将原来的优先级120调到90,再使用tracert命令跟踪路由,发现路由走的是右边的网络。这时候右边的是Master.
        而且当你立刻改回来,再去使用tracert命令跟踪的时候,网络不会立刻走回左边的网络,在前面的配置中配置了抢占延迟的时间为20 S,因此在恢复优先级后,要等过了设置的抢占延时时间才可以恢复。
        14.跟踪上行接口,如果上行结果有故障,则优先级会-30,那么原来的Master会变成backup,则网络则通过一边的进行传送。

[csw1-Vlanif10]vrrp vrid 10 track interface g0/0/2 reduced 30
[csw1]int g0/0/2
[csw1-GigabitEthernet0/0/2]shutdown
[csw1-GigabitEthernet0/0/2]quit
[csw1]display vrrp
  Vlanif10 | Virtual Router 10
    State : Backup
    Virtual IP : 192.168.10.254
    Master IP : 192.168.10.253
    PriorityRun : 90
    PriorityConfig : 120
    MasterPriority : 100
    Preempt : YES   Delay Time : 20 s
    TimerRun : 1 s
    TimerConfig : 1 s
    Auth type : NONE
    Virtual MAC : 0000-5e00-010a
    Check TTL : YES
    Config type : normal-vrrp
    Track IF : GigabitEthernet0/0/2   Priority reduced : 30
    IF state : DOWN
    Create time : 2023-05-06 15:13:45 UTC-08:00
    Last change time : 2023-05-06 15:59:43 UTC-08:00

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐