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

简介: 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

可以自己试试


[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


目录
相关文章
|
21天前
|
网络协议 安全 网络安全
Cisco-网络端口地址转换NAPT配置
Cisco-网络端口地址转换NAPT配置
|
27天前
|
网络协议 Linux Windows
Rsyslog配置不同端口收集不同设备日志
Rsyslog配置不同端口收集不同设备日志
|
21天前
|
安全 网络安全 数据安全/隐私保护
Cisco-交换机配置聚合端口
Cisco-交换机配置聚合端口
|
24天前
|
网络架构
【第二期】计算机网络常识(端口/网段/路由)
【第二期】计算机网络常识(端口/网段/路由)
37 0
|
3月前
|
运维 网络协议 网络安全
干货 | USG配置端口映射图解&amp;映射不通的排查
干货 | USG配置端口映射图解&amp;映射不通的排查
119 9
|
3月前
|
开发框架 .NET Linux
【Azure 应用服务】 部署到App Service for Linux 服务的Docker 镜像,如何配置监听端口呢?
【Azure 应用服务】 部署到App Service for Linux 服务的Docker 镜像,如何配置监听端口呢?
|
4月前
|
监控 关系型数据库 分布式数据库
PolarDB产品使用问题之如何配置端口
PolarDB产品使用合集涵盖了从创建与管理、数据管理、性能优化与诊断、安全与合规到生态与集成、运维与支持等全方位的功能和服务,旨在帮助企业轻松构建高可用、高性能且易于管理的数据库环境,满足不同业务场景的需求。用户可以通过阿里云控制台、API、SDK等方式便捷地使用这些功能,实现数据库的高效运维与持续优化。
|
4月前
|
Java Redis 数据安全/隐私保护
Redis14----Redis的java客户端-jedis的连接池,jedis本身是线程不安全的,并且频繁的创建和销毁连接会有性能损耗,最好用jedis连接池代替jedis,配置端口,密码
Redis14----Redis的java客户端-jedis的连接池,jedis本身是线程不安全的,并且频繁的创建和销毁连接会有性能损耗,最好用jedis连接池代替jedis,配置端口,密码
JWT令牌,JWT令牌的后续使用,在其他端口中使用的注意事项?如果你编写了JWT令牌的话,在下一次请求当中,都需要添加的,如果你已经配置好了WebConfig和Inter 就不用配了,添加了拦截器之后
JWT令牌,JWT令牌的后续使用,在其他端口中使用的注意事项?如果你编写了JWT令牌的话,在下一次请求当中,都需要添加的,如果你已经配置好了WebConfig和Inter 就不用配了,添加了拦截器之后
|
5月前
|
网络协议 Linux Shell
如何在 CentOS 中配置 SSH 服务的 TCP 端口转发
如何在 CentOS 中配置 SSH 服务的 TCP 端口转发
225 0