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


    以下配置图为例

    PC1的配置

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

    1. <Huawei>sys
    2. Enter system view, return user view with Ctrl+Z.
    3. [Huawei]sysname acsw
    4. [acsw]
    5. Sep 11 2023 18:15:48-08:00 acsw DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.2
    6. 5.191.3.1 configurations have been changed. The current change number is 4, the
    7. change loop count is 0, and the maximum number of records is 4095.
    8. [acsw]undo info-center enable
    9. Info: Information center is disabled.
    10. [acsw]vlan 10
    11. [acsw-vlan100]int g0/0/3
    12. [acsw-GigabitEthernet0/0/3]port link-type access
    13. [acsw-GigabitEthernet0/0/3]port default vlan 10
    14. [acsw-GigabitEthernet0/0/3]qu
    15. [acsw]int g0/0/1
    16. [acsw-GigabitEthernet0/0/1]port link-type trunk
    17. [acsw-GigabitEthernet0/0/1]port trunk allow-pass vlan all
    18. [acsw-GigabitEthernet0/0/1]int g0/0/2
    19. [acsw-GigabitEthernet0/0/2]port link-type trunk
    20. [acsw-GigabitEthernet0/0/2]port trunk allow-pass vlan all
    21. [acsw-GigabitEthernet0/0/2]qu
    22. [acsw]

     核心交换机1的配置

    1. <Huawei>sys
    2. Enter system view, return user view with Ctrl+Z.
    3. [Huawei]sysname coresw1
    4. [coresw1]
    5. Sep 11 2023 21:33:29-08:00 coresw1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.
    6. 5.25.191.3.1 configurations have been changed. The current change number is 4, t
    7. he change loop count is 0, and the maximum number of records is 4095.
    8. [coresw1]undo info-center enable
    9. Info: Information center is disabled.
    10. [coresw1]interface g0/0/1
    11. [coresw1-GigabitEthernet0/0/1]port link-type trunk
    12. [coresw1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
    13. [coresw1-GigabitEthernet0/0/1]int g0/0/3
    14. [coresw1-GigabitEthernet0/0/3]port link-type trunk
    15. [coresw1-GigabitEthernet0/0/3]port trunk allow-pass vlan all
    16. [coresw1-GigabitEthernet0/0/3]q
    17. [coresw1]vlan 10
    18. [coresw1-vlan10]q
    19. [coresw1]vlan 100
    20. [coresw1-vlan100]q
    21. [coresw1]int g0/0/2
    22. [coresw1-GigabitEthernet0/0/2]port link-type access
    23. [coresw1-GigabitEthernet0/0/2]port default vlan 100
    24. [coresw1-GigabitEthernet0/0/2]q
    25. [coresw1]interface vlanif 10
    26. [coresw1-Vlanif10]ip address 192.168.10.252 24
    27. [coresw1-Vlanif10]qu
    28. [coresw1]interface vlanif 100
    29. [coresw1-Vlanif100]ip add 192.168.100.1 30
    30. [coresw1-Vlanif100]qu
    31. <coresw1>sys
    32. Enter system view, return user view with Ctrl+Z.
    33. [coresw1]interface vlanif 10
    34. #必配
    35. [coresw1-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
    36. #选配
    37. [coresw1-Vlanif10]vrrp vrid 10 priority 120
    38. [coresw1-Vlanif10]vrrp vrid 10 preempt-mode time delay 20
    39. [coresw1-Vlanif10]qu
    40. [coresw1]
    41. [coresw1]display vrrp
    42. Vlanif10 | Virtual Router 10
    43. State : Master
    44. Virtual IP : 192.168.10.254
    45. Master IP : 192.168.10.252
    46. PriorityRun : 120
    47. PriorityConfig : 120
    48. MasterPriority : 120
    49. Preempt : YES Delay Time : 20 s
    50. TimerRun : 1 s
    51. TimerConfig : 1 s
    52. Auth type : NONE
    53. Virtual MAC : 0000-5e00-010a
    54. Check TTL : YES
    55. Config type : normal-vrrp
    56. Create time : 2023-09-11 21:57:31 UTC-08:00
    57. Last change time : 2023-09-11 21:57:35 UTC-08:00
    58. #抢占延迟20秒的作用
    59. 这里我们先将coresw1
    60. vrrp vrid 10 priority 90
    61. 在变为
    62. vrrp vrid 10 priority 120
    63. 我们通过tracert路径可以看见,还是走coresw2,这就是因为有抢占延迟

    核心交换机2的配置

    1. <Huawei>
    2. <Huawei>sys
    3. Enter system view, return user view with Ctrl+Z.
    4. [Huawei]sysname coresw2
    5. [coresw2]
    6. Sep 11 2023 21:48:13-08:00 coresw2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.
    7. 5.25.191.3.1 configurations have been changed. The current change number is 4, t
    8. he change loop count is 0, and the maximum number of records is 4095.
    9. [coresw2]undo info-center enable
    10. Info: Information center is disabled.
    11. [coresw2]interface g0/0/1
    12. [coresw2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
    13. [coresw2-GigabitEthernet0/0/1]int g0/0/3
    14. [coresw2-GigabitEthernet0/0/3]p l t
    15. [coresw2-GigabitEthernet0/0/3]port trunk allow vlan all
    16. [coresw2-GigabitEthernet0/0/3]qu
    17. [coresw2]vlan 10
    18. [coresw2-vlan10]vlan 200
    19. [coresw2-vlan200]qu
    20. [coresw2]interface g0/0/2
    21. [coresw2-GigabitEthernet0/0/2]port link-type access
    22. [coresw2-GigabitEthernet0/0/2]port default vlan 200
    23. [coresw2-GigabitEthernet0/0/2]qu
    24. [coresw2]int vlanif 10
    25. [coresw2-Vlanif10]ip add 192.168.10.253 24
    26. [coresw2-Vlanif10]interface vlan 200
    27. [coresw2-Vlanif200]ip address 192.168.200.1 30
    28. [coresw2-Vlanif200]
    29. [coresw2-Vlanif200]ping 192.168.10.252
    30. PING 192.168.10.252: 56 data bytes, press CTRL_C to break
    31. Reply from 192.168.10.252: bytes=56 Sequence=1 ttl=255 time=130 ms
    32. Reply from 192.168.10.252: bytes=56 Sequence=2 ttl=255 time=60 ms
    33. Reply from 192.168.10.252: bytes=56 Sequence=3 ttl=255 time=70 ms
    34. Reply from 192.168.10.252: bytes=56 Sequence=4 ttl=255 time=60 ms
    35. Reply from 192.168.10.252: bytes=56 Sequence=5 ttl=255 time=70 ms
    36. [coresw2]
    37. [coresw2]int vlanif 10
    38. #必选
    39. [coresw2-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
    40. [coresw2-Vlanif10]
    41. #默认优先级是100,但是第一个核心交换机为120,所以第一个是master
    42. [coresw2-Vlanif10]qu
    43. [coresw2]display vrrp
    44. Vlanif10 | Virtual Router 10
    45. State : Backup
    46. Virtual IP : 192.168.10.254
    47. Master IP : 192.168.10.252
    48. PriorityRun : 100
    49. PriorityConfig : 100
    50. MasterPriority : 120
    51. Preempt : YES Delay Time : 0 s
    52. TimerRun : 1 s
    53. TimerConfig : 1 s
    54. Auth type : NONE
    55. Virtual MAC : 0000-5e00-010a
    56. Check TTL : YES
    57. Config type : normal-vrrp
    58. Create time : 2023-09-11 22:05:51 UTC-08:00
    59. Last change time : 2023-09-11 22:05:51 UTC-08:00
    60. [coresw2]

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

    1. PC>ping 192.168.10.254
    2. Ping 192.168.10.254: 32 data bytes, Press Ctrl_C to break
    3. From 192.168.10.254: bytes=32 seq=1 ttl=255 time=31 ms
    4. From 192.168.10.254: bytes=32 seq=2 ttl=255 time=31 ms
    5. From 192.168.10.254: bytes=32 seq=3 ttl=255 time=47 ms
    6. From 192.168.10.254: bytes=32 seq=4 ttl=255 time=47 ms
    7. From 192.168.10.254: bytes=32 seq=5 ttl=255 time=31 ms
    8. --- 192.168.10.254 ping statistics ---
    9. 5 packet(s) transmitted
    10. 5 packet(s) received
    11. 0.00% packet loss
    12. round-trip min/avg/max = 31/37/47 ms

    AR1的配置

    1. <Huawei>sys
    2. Enter system view, return user view with Ctrl+Z.
    3. [Huawei]sysname AR1
    4. [AR1]interface g0/0/1
    5. [AR1-GigabitEthernet0/0/1]ip add 192.168.100.2 30
    6. Sep 11 2023 22:16:34-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
    7. on the interface GigabitEthernet0/0/1 has entered the UP state.
    8. [AR1-GigabitEthernet0/0/1]int g0/0/2
    9. [AR1-GigabitEthernet0/0/2]ip add 192.168.200.2 30
    10. [AR1-GigabitEthernet0/0/2]
    11. Sep 11 2023 22:17:17-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
    12. on the interface GigabitEthernet0/0/2 has entered the UP state.
    13. [AR1-GigabitEthernet0/0/2]int g0/0/0
    14. [AR1-GigabitEthernet0/0/0]ip add 100.1.1.2 30
    15. [AR1-GigabitEthernet0/0/0]
    16. Sep 11 2023 22:17:39-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
    17. on the interface GigabitEthernet0/0/0 has entered the UP state.
    18. [AR1-GigabitEthernet0/0/0]q
    19. #ping直连
    20. [AR1]ping 192.168.100.1
    21. PING 192.168.100.1: 56 data bytes, press CTRL_C to break
    22. Reply from 192.168.100.1: bytes=56 Sequence=1 ttl=255 time=50 ms
    23. Reply from 192.168.100.1: bytes=56 Sequence=2 ttl=255 time=10 ms
    24. Reply from 192.168.100.1: bytes=56 Sequence=3 ttl=255 time=10 ms
    25. Reply from 192.168.100.1: bytes=56 Sequence=4 ttl=255 time=30 ms
    26. Reply from 192.168.100.1: bytes=56 Sequence=5 ttl=255 time=20 ms
    27. --- 192.168.100.1 ping statistics ---
    28. 5 packet(s) transmitted
    29. 5 packet(s) received
    30. 0.00% packet loss
    31. round-trip min/avg/max = 10/24/50 ms
    32. [AR1]ping 192.168.200.1
    33. PING 192.168.200.1: 56 data bytes, press CTRL_C to break
    34. Reply from 192.168.200.1: bytes=56 Sequence=1 ttl=255 time=50 ms
    35. Reply from 192.168.200.1: bytes=56 Sequence=2 ttl=255 time=20 ms
    36. Reply from 192.168.200.1: bytes=56 Sequence=3 ttl=255 time=10 ms
    37. Reply from 192.168.200.1: bytes=56 Sequence=4 ttl=255 time=30 ms
    38. Reply from 192.168.200.1: bytes=56 Sequence=5 ttl=255 time=10 ms
    39. --- 192.168.200.1 ping statistics ---
    40. 5 packet(s) transmitted
    41. 5 packet(s) received
    42. 0.00% packet loss
    43. round-trip min/avg/max = 10/24/50 ms

     互联网的配置

    1. sys
    2. int g0/0/0
    3. ip add 100.1.1.1 30

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

    1. <coresw1>display ip routing-table
    2. Route Flags: R - relay, D - download to fib
    3. ------------------------------------------------------------------------------
    4. Routing Tables: Public
    5. Destinations : 7 Routes : 7
    6. Destination/Mask Proto Pre Cost Flags NextHop Interface
    7. 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
    8. 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
    9. 192.168.10.0/24 Direct 0 0 D 192.168.10.252 Vlanif10
    10. 192.168.10.252/32 Direct 0 0 D 127.0.0.1 Vlanif10
    11. 192.168.10.254/32 Direct 0 0 D 127.0.0.1 Vlanif10
    12. 192.168.100.0/30 Direct 0 0 D 192.168.100.1 Vlanif100
    13. 192.168.100.1/32 Direct 0 0 D 127.0.0.1 Vlanif100

    重要的一步

    1. #配置默认路由,5080都可以
    2. [coresw1]ip route-static 0.0.0.0 0.0.0.0 192.168.100.2
    3. [coresw2]ip route-static 0.0.0.0 0 192.168.200.2

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

    1. #静态ip
    2. ip route-static 192.168.10.0 24 100.1.1.2
    3. #默认路由
    4. ip route-static 0.0.0.0 0 100.1.1.2

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

    1. [AR1]display ip routing-table
    2. Route Flags: R - relay, D - download to fib
    3. ------------------------------------------------------------------------------
    4. Routing Tables: Public
    5. Destinations : 13 Routes : 13
    6. Destination/Mask Proto Pre Cost Flags NextHop Interface
    7. 100.1.1.0/30 Direct 0 0 D 100.1.1.2 GigabitEthernet
    8. 0/0/0
    9. 100.1.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
    10. 0/0/0
    11. 100.1.1.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
    12. 0/0/0
    13. 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
    14. 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
    15. 127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
    16. 192.168.100.0/30 Direct 0 0 D 192.168.100.2 GigabitEthernet
    17. 0/0/1
    18. 192.168.100.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
    19. 0/0/1
    20. 192.168.100.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
    21. 0/0/1
    22. 192.168.200.0/30 Direct 0 0 D 192.168.200.2 GigabitEthernet
    23. 0/0/2
    24. 192.168.200.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
    25. 0/0/2
    26. 192.168.200.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
    27. 0/0/2
    28. 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0

     所以AR1还需要配静态路由

    1. [AR1]ip route-static 192.168.10.0 24 192.168.100.1
    2. [AR1]ip route-static 192.168.10.0 24 192.168.200.1

     现在终于可以ping通啦!!

    注:

    可以用tracert观察路径

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

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

    可以自己试试

    1. [coresw1]int g0/0/2
    2. [coresw1-GigabitEthernet0/0/2]shutdown
    3. [coresw1-GigabitEthernet0/0/2]qu
    4. [coresw1]display vrrp
    5. Vlanif10 | Virtual Router 10
    6. State : Master
    7. Virtual IP : 192.168.10.254
    8. Master IP : 192.168.10.252
    9. PriorityRun : 90
    10. PriorityConfig : 120
    11. MasterPriority : 90
    12. Preempt : YES Delay Time : 20 s
    13. TimerRun : 1 s
    14. TimerConfig : 1 s
    15. Auth type : NONE
    16. Virtual MAC : 0000-5e00-010a
    17. Check TTL : YES
    18. Config type : normal-vrrp
    19. Track IF : GigabitEthernet0/0/2 Priority reduced : 30
    20. IF state : DOWN
    21. Create time : 2023-09-11 21:57:31 UTC-08:00
    22. Last change time : 2023-09-11 21:57:35 UTC-08:00
    23. [coresw2]display vrrp
    24. Vlanif10 | Virtual Router 10
    25. State : Master
    26. Virtual IP : 192.168.10.254
    27. Master IP : 192.168.10.253
    28. PriorityRun : 120
    29. PriorityConfig : 120
    30. MasterPriority : 120
    31. Preempt : YES Delay Time : 20 s
    32. TimerRun : 1 s
    33. TimerConfig : 1 s
    34. Auth type : NONE
    35. Virtual MAC : 0000-5e00-010a
    36. Check TTL : YES
    37. Config type : normal-vrrp
    38. Create time : 2023-09-11 22:05:51 UTC-08:00
    39. Last change time : 2023-09-11 22:56:50 UTC-08:00
  • 相关阅读:
    Spark集群中一个Worker节点启动失败的排错记录
    实现一个极简的字节数组对象池
    扰动算法(哈希函数)
    Java项目:SSH的自动排课系统-遗传算法
    frp内网穿透ssh,tcp经过服务器慢速和p2p模式实现高速吃满上传带宽
    2个比较经典的PHP加密解密函数分享
    HTML静态网页成品作业(HTML+CSS)——贵州美食介绍设计制作(1个页面)
    项目管理——评审中的误区
    C++多态(2)
    【JavaScript】一文了解定时器的使用
  • 原文地址:https://blog.csdn.net/weixin_69884785/article/details/132814583