VRRP配置案例(路由走向分析,端口切换)

以下配置图为例

PC1的配置

acsw下行为access口,上行为trunk口, 将g0/0/3划分到vlan100中

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname acsw
[acsw]
Sep 11 2023 18:15:48-08:00 acsw DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.2
5.191.3.1 configurations have been changed. The current change number is 4, the 
change loop count is 0, and the maximum number of records is 4095.
[acsw]undo info-center enable
Info: Information center is disabled.
[acsw]vlan 10

[acsw-vlan100]int g0/0/3
[acsw-GigabitEthernet0/0/3]port link-type access

[acsw-GigabitEthernet0/0/3]port default vlan 10
[acsw-GigabitEthernet0/0/3]qu

[acsw]int 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]int 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]qu
[acsw]

 核心交换机1的配置

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname coresw1
[coresw1]
Sep 11 2023 21:33:29-08:00 coresw1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.
5.25.191.3.1 configurations have been changed. The current change number is 4, t
he change loop count is 0, and the maximum number of records is 4095.
[coresw1]undo info-center enable
Info: Information center is disabled.
[coresw1]interface g0/0/1
[coresw1-GigabitEthernet0/0/1]port link-type trunk
[coresw1-GigabitEthernet0/0/1]port trunk allow-pass vlan all

[coresw1-GigabitEthernet0/0/1]int g0/0/3
[coresw1-GigabitEthernet0/0/3]port link-type trunk
[coresw1-GigabitEthernet0/0/3]port trunk allow-pass vlan all
[coresw1-GigabitEthernet0/0/3]q

[coresw1]vlan 10
[coresw1-vlan10]q
[coresw1]vlan 100
[coresw1-vlan100]q
[coresw1]int g0/0/2
[coresw1-GigabitEthernet0/0/2]port link-type access
[coresw1-GigabitEthernet0/0/2]port default vlan 100
[coresw1-GigabitEthernet0/0/2]q

[coresw1]interface vlanif 10
[coresw1-Vlanif10]ip address 192.168.10.252 24
[coresw1-Vlanif10]qu

[coresw1]interface vlanif 100
[coresw1-Vlanif100]ip add 192.168.100.1 30
[coresw1-Vlanif100]qu

<coresw1>sys
Enter system view, return user view with Ctrl+Z.
[coresw1]interface vlanif 10
#必配
[coresw1-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
#选配
[coresw1-Vlanif10]vrrp vrid 10 priority 120
[coresw1-Vlanif10]vrrp vrid 10 preempt-mode time delay 20
[coresw1-Vlanif10]qu
[coresw1]
[coresw1]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-09-11 21:57:31 UTC-08:00
    Last change time : 2023-09-11 21:57:35 UTC-08:00

#抢占延迟20秒的作用
这里我们先将coresw1
vrrp vrid 10 priority 90
在变为
vrrp vrid 10 priority 120
我们通过tracert路径可以看见,还是走coresw2,这就是因为有抢占延迟

核心交换机2的配置

<Huawei>
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname coresw2
[coresw2]
Sep 11 2023 21:48:13-08:00 coresw2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.
5.25.191.3.1 configurations have been changed. The current change number is 4, t
he change loop count is 0, and the maximum number of records is 4095.
[coresw2]undo info-center enable
Info: Information center is disabled.
[coresw2]interface g0/0/1
[coresw2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[coresw2-GigabitEthernet0/0/1]int g0/0/3
[coresw2-GigabitEthernet0/0/3]p l t
[coresw2-GigabitEthernet0/0/3]port trunk allow vlan all
[coresw2-GigabitEthernet0/0/3]qu
[coresw2]vlan 10
[coresw2-vlan10]vlan 200
[coresw2-vlan200]qu
[coresw2]interface g0/0/2
[coresw2-GigabitEthernet0/0/2]port link-type access
[coresw2-GigabitEthernet0/0/2]port default vlan 200
[coresw2-GigabitEthernet0/0/2]qu
[coresw2]int vlanif 10
[coresw2-Vlanif10]ip add 192.168.10.253 24
[coresw2-Vlanif10]interface vlan 200
[coresw2-Vlanif200]ip address 192.168.200.1 30
[coresw2-Vlanif200]
[coresw2-Vlanif200]ping 192.168.10.252
  PING 192.168.10.252: 56  data bytes, press CTRL_C to break
    Reply from 192.168.10.252: bytes=56 Sequence=1 ttl=255 time=130 ms
    Reply from 192.168.10.252: bytes=56 Sequence=2 ttl=255 time=60 ms
    Reply from 192.168.10.252: bytes=56 Sequence=3 ttl=255 time=70 ms
    Reply from 192.168.10.252: bytes=56 Sequence=4 ttl=255 time=60 ms
    Reply from 192.168.10.252: bytes=56 Sequence=5 ttl=255 time=70 ms

[coresw2]  
[coresw2]int vlanif 10
#必选
[coresw2-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
[coresw2-Vlanif10]
#默认优先级是100,但是第一个核心交换机为120,所以第一个是master
[coresw2-Vlanif10]qu

[coresw2]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-09-11 22:05:51 UTC-08:00
    Last change time : 2023-09-11 22:05:51 UTC-08:00

[coresw2]

ping 网关,是master,即coresw1进行回应

PC>ping 192.168.10.254

Ping 192.168.10.254: 32 data bytes, Press Ctrl_C to break
From 192.168.10.254: bytes=32 seq=1 ttl=255 time=31 ms
From 192.168.10.254: bytes=32 seq=2 ttl=255 time=31 ms
From 192.168.10.254: bytes=32 seq=3 ttl=255 time=47 ms
From 192.168.10.254: bytes=32 seq=4 ttl=255 time=47 ms
From 192.168.10.254: bytes=32 seq=5 ttl=255 time=31 ms

--- 192.168.10.254 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 31/37/47 ms

AR1的配置

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname AR1
[AR1]interface g0/0/1
[AR1-GigabitEthernet0/0/1]ip add 192.168.100.2 30
Sep 11 2023 22:16:34-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
 on the interface GigabitEthernet0/0/1 has entered the UP state. 
[AR1-GigabitEthernet0/0/1]int g0/0/2
[AR1-GigabitEthernet0/0/2]ip add 192.168.200.2 30
[AR1-GigabitEthernet0/0/2]
Sep 11 2023 22:17:17-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
 on the interface GigabitEthernet0/0/2 has entered the UP state. 
[AR1-GigabitEthernet0/0/2]int g0/0/0 
[AR1-GigabitEthernet0/0/0]ip add 100.1.1.2 30
[AR1-GigabitEthernet0/0/0]
Sep 11 2023 22:17:39-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
 on the interface GigabitEthernet0/0/0 has entered the UP state. 
[AR1-GigabitEthernet0/0/0]q
#ping直连
[AR1]ping 192.168.100.1
  PING 192.168.100.1: 56  data bytes, press CTRL_C to break
    Reply from 192.168.100.1: bytes=56 Sequence=1 ttl=255 time=50 ms
    Reply from 192.168.100.1: bytes=56 Sequence=2 ttl=255 time=10 ms
    Reply from 192.168.100.1: bytes=56 Sequence=3 ttl=255 time=10 ms
    Reply from 192.168.100.1: bytes=56 Sequence=4 ttl=255 time=30 ms
    Reply from 192.168.100.1: bytes=56 Sequence=5 ttl=255 time=20 ms

  --- 192.168.100.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 10/24/50 ms

[AR1]ping 192.168.200.1
  PING 192.168.200.1: 56  data bytes, press CTRL_C to break
    Reply from 192.168.200.1: bytes=56 Sequence=1 ttl=255 time=50 ms
    Reply from 192.168.200.1: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 192.168.200.1: bytes=56 Sequence=3 ttl=255 time=10 ms
    Reply from 192.168.200.1: bytes=56 Sequence=4 ttl=255 time=30 ms
    Reply from 192.168.200.1: bytes=56 Sequence=5 ttl=255 time=10 ms

  --- 192.168.200.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 10/24/50 ms

 互联网的配置

sys
int g0/0/0
ip add 100.1.1.1 30

 到这里PC1仍然ping不通互联网,PC1与互联网并不在一个网段,就到达网关(coresw1)

<coresw1>display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 7        Routes : 7        

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

      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
   192.168.10.0/24  Direct  0    0           D   192.168.10.252  Vlanif10
 192.168.10.252/32  Direct  0    0           D   127.0.0.1       Vlanif10
 192.168.10.254/32  Direct  0    0           D   127.0.0.1       Vlanif10
  192.168.100.0/30  Direct  0    0           D   192.168.100.1   Vlanif100
  192.168.100.1/32  Direct  0    0           D   127.0.0.1       Vlanif100

重要的一步

#配置默认路由,5个0,8个0都可以
[coresw1]ip route-static 0.0.0.0 0.0.0.0 192.168.100.2

[coresw2]ip route-static 0.0.0.0 0 192.168.200.2

到达这一步,再配置互联网的回程路由
这里可以写静态路由,也可以写默认路由

#静态ip
ip route-static 192.168.10.0 24 100.1.1.2

#默认路由
ip route-static 0.0.0.0 0 100.1.1.2

 这里AR1没有目的地址:192.168.10.1的路由 

[AR1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 13       Routes : 13       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

      100.1.1.0/30  Direct  0    0           D   100.1.1.2       GigabitEthernet
0/0/0
      100.1.1.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
      100.1.1.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
      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
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
  192.168.100.0/30  Direct  0    0           D   192.168.100.2   GigabitEthernet
0/0/1
  192.168.100.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
  192.168.100.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
  192.168.200.0/30  Direct  0    0           D   192.168.200.2   GigabitEthernet
0/0/2
  192.168.200.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/2
  192.168.200.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/2
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

 所以AR1还需要配静态路由

[AR1]ip route-static 192.168.10.0 24 192.168.100.1
[AR1]ip route-static 192.168.10.0 24 192.168.200.1

 现在终于可以ping通啦!!

注:

可以用tracert观察路径

 最后一个问题:端口的切换

#如果g0/0/2接口down了,那么其优先级变为120-30=90,那么master会变为coresw2
[coresw1]interface vlanif 10
[coresw1-Vlanif10]vrrp vrid 10 track interface g0/0/2
[coresw1-Vlanif10]vrrp vrid 10 track interface g0/0/2 reduced 30

可以自己试试文章来源地址https://www.uudwc.com/A/vmWVR/

[coresw1]int g0/0/2
[coresw1-GigabitEthernet0/0/2]shutdown
[coresw1-GigabitEthernet0/0/2]qu
[coresw1]display vrrp
  Vlanif10 | Virtual Router 10
    State : Master
    Virtual IP : 192.168.10.254
    Master IP : 192.168.10.252
    PriorityRun : 90
    PriorityConfig : 120
    MasterPriority : 90
    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-09-11 21:57:31 UTC-08:00
    Last change time : 2023-09-11 21:57:35 UTC-08:00



[coresw2]display vrrp
  Vlanif10 | Virtual Router 10
    State : Master
    Virtual IP : 192.168.10.254
    Master IP : 192.168.10.253
    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-09-11 22:05:51 UTC-08:00
    Last change time : 2023-09-11 22:56:50 UTC-08:00

原文地址:https://blog.csdn.net/weixin_69884785/article/details/132814583

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请联系站长进行投诉反馈,一经查实,立即删除!

h
上一篇 2023年10月28日 05:08
什么是物联网智慧公厕?
下一篇 2023年10月28日 06:08