当前位置: 首页 > news >正文

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 vrrpVlanif10 | Virtual Router 10State : MasterVirtual IP : 192.168.10.254Master IP : 192.168.10.252PriorityRun : 120PriorityConfig : 120MasterPriority : 120Preempt : YES   Delay Time : 20 sTimerRun : 1 sTimerConfig : 1 sAuth type : NONEVirtual MAC : 0000-5e00-010aCheck TTL : YESConfig type : normal-vrrpCreate time : 2023-09-11 21:57:31 UTC-08:00Last 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.252PING 192.168.10.252: 56  data bytes, press CTRL_C to breakReply from 192.168.10.252: bytes=56 Sequence=1 ttl=255 time=130 msReply from 192.168.10.252: bytes=56 Sequence=2 ttl=255 time=60 msReply from 192.168.10.252: bytes=56 Sequence=3 ttl=255 time=70 msReply from 192.168.10.252: bytes=56 Sequence=4 ttl=255 time=60 msReply 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 vrrpVlanif10 | Virtual Router 10State : BackupVirtual IP : 192.168.10.254Master IP : 192.168.10.252PriorityRun : 100PriorityConfig : 100MasterPriority : 120Preempt : YES   Delay Time : 0 sTimerRun : 1 sTimerConfig : 1 sAuth type : NONEVirtual MAC : 0000-5e00-010aCheck TTL : YESConfig type : normal-vrrpCreate time : 2023-09-11 22:05:51 UTC-08:00Last change time : 2023-09-11 22:05:51 UTC-08:00[coresw2]

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

PC>ping 192.168.10.254Ping 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) transmitted5 packet(s) received0.00% packet lossround-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 IPon 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 IPon 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 IPon the interface GigabitEthernet0/0/0 has entered the UP state. 
[AR1-GigabitEthernet0/0/0]q
#ping直连
[AR1]ping 192.168.100.1PING 192.168.100.1: 56  data bytes, press CTRL_C to breakReply from 192.168.100.1: bytes=56 Sequence=1 ttl=255 time=50 msReply from 192.168.100.1: bytes=56 Sequence=2 ttl=255 time=10 msReply from 192.168.100.1: bytes=56 Sequence=3 ttl=255 time=10 msReply from 192.168.100.1: bytes=56 Sequence=4 ttl=255 time=30 msReply from 192.168.100.1: bytes=56 Sequence=5 ttl=255 time=20 ms--- 192.168.100.1 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 10/24/50 ms[AR1]ping 192.168.200.1PING 192.168.200.1: 56  data bytes, press CTRL_C to breakReply from 192.168.200.1: bytes=56 Sequence=1 ttl=255 time=50 msReply from 192.168.200.1: bytes=56 Sequence=2 ttl=255 time=20 msReply from 192.168.200.1: bytes=56 Sequence=3 ttl=255 time=10 msReply from 192.168.200.1: bytes=56 Sequence=4 ttl=255 time=30 msReply from 192.168.200.1: bytes=56 Sequence=5 ttl=255 time=10 ms--- 192.168.200.1 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-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: PublicDestinations : 7        Routes : 7        Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0192.168.10.0/24  Direct  0    0           D   192.168.10.252  Vlanif10192.168.10.252/32  Direct  0    0           D   127.0.0.1       Vlanif10192.168.10.254/32  Direct  0    0           D   127.0.0.1       Vlanif10192.168.100.0/30  Direct  0    0           D   192.168.100.1   Vlanif100192.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: PublicDestinations : 13       Routes : 13       Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface100.1.1.0/30  Direct  0    0           D   100.1.1.2       GigabitEthernet
0/0/0100.1.1.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0100.1.1.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0127.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       InLoopBack0192.168.100.0/30  Direct  0    0           D   192.168.100.2   GigabitEthernet
0/0/1192.168.100.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1192.168.100.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1192.168.200.0/30  Direct  0    0           D   192.168.200.2   GigabitEthernet
0/0/2192.168.200.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/2192.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 vrrpVlanif10 | Virtual Router 10State : MasterVirtual IP : 192.168.10.254Master IP : 192.168.10.252PriorityRun : 90PriorityConfig : 120MasterPriority : 90Preempt : YES   Delay Time : 20 sTimerRun : 1 sTimerConfig : 1 sAuth type : NONEVirtual MAC : 0000-5e00-010aCheck TTL : YESConfig type : normal-vrrpTrack IF : GigabitEthernet0/0/2   Priority reduced : 30IF state : DOWNCreate time : 2023-09-11 21:57:31 UTC-08:00Last change time : 2023-09-11 21:57:35 UTC-08:00[coresw2]display vrrpVlanif10 | Virtual Router 10State : MasterVirtual IP : 192.168.10.254Master IP : 192.168.10.253PriorityRun : 120PriorityConfig : 120MasterPriority : 120Preempt : YES   Delay Time : 20 sTimerRun : 1 sTimerConfig : 1 sAuth type : NONEVirtual MAC : 0000-5e00-010aCheck TTL : YESConfig type : normal-vrrpCreate time : 2023-09-11 22:05:51 UTC-08:00Last change time : 2023-09-11 22:56:50 UTC-08:00
http://www.lryc.cn/news/181017.html

相关文章:

  • 【图像处理】【应用程序设计】加载,编辑和保存图像数据、图像分割、色度键控研究(Matlab代码实现)
  • 05. 机器学习入门 - 动态规划
  • 【JVM】第五篇 垃圾收集器G1和ZGC详解
  • 嵌入式Linux应用开发-基础知识-第十九章驱动程序基石⑤
  • 数据分析技能点-独立性检验拟合优度检验
  • 了解汽车ecu组成
  • 用AI原生向量数据库Milvus Cloud 搭建一个 AI 聊天机器人
  • 【OpenCV-Torch-dlib-ubuntu】Vm虚拟机linux环境摄像头调用方法与dilb模型探究
  • (二)详解观察者模式
  • 嵌入式Linux应用开发-基础知识-第十九章驱动程序基石④
  • 2023 彩虹全新 SUP 模板,卡卡云模板修复版
  • 【AI视野·今日NLP 自然语言处理论文速览 第四十一期】Tue, 26 Sep 2023
  • 【iptables 实战】05 iptables设置网络转发实验
  • pygame - 贪吃蛇小游戏
  • 基于 QT 实现 Task Timer,高效利用时间
  • 图像处理与计算机视觉--第五章-图像分割-霍夫变换
  • linux下文件操作命令
  • Golang语法、技巧和窍门
  • Grander因果检验(格兰杰)原理+操作+解释
  • Python-Flask:编写自动化连接demo脚本:v1.0.0
  • kafka客户端应用参数详解
  • Apache Doris 行列转换可以这样玩
  • 【Qt图形视图框架】自定义QGraphicsItem和QGraphicsView,实现鼠标(移动、缩放)及键盘事件、右键事件
  • C语言结构体指针学习
  • 华为云云耀云服务器L实例评测|部署在线轻量级备忘录 memos
  • 详解Avast Driver Updater:电脑驱动更新工具的利器还是多余的软件?
  • 大数据Flink(九十五):DML:Window TopN
  • 使用OKHttpClient访问网络
  • maui 开发AMD CPU踩的坑。
  • 宝塔反代openai官方API接口详细教程,502 Bad Gateway问题解决