静态路由实现路由负载分担

组网图形

    

静态路由简介

组网需求

  • 如图1所示,PC1和PC2通过4台Switch相连,从拓扑图中可以看出,数据从PC1到PC2有两条路径可以到达,分别是PC1-SwitchA-SwitchB-SwitchC-PC2和PC1-SwitchA-SwitchD-SwitchC-PC2,为了有效利用链路,要求从PC1到PC2的数据流平均分配到两条链路上,而且当一条链路故障之后数据流自动切换到另一条链路上去。

配置思路

  • 1.创建VLAN并配置各接口所属VLAN,配置各VLANIF接口的IP地址。
  • 2.配置数据流来回两个方向的静态路由。
  • 3.在各主机上配置IP地址和默认网关。

操作步骤

  • 1.配置各接口所属VLAN

  # 配置SwitchA。SwitchB、SwitchC和SwitchD的配置与SwitchA类似,不再赘述。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<HUAWEI> system-view
[HUAWEI] sysname SwitchA
[SwitchA] vlan batch 10 100 400
[SwitchA] interface gigabitethernet 0/0/1
[SwitchA-GigabitEthernet0/0/1] port link-type access
[SwitchA-GigabitEthernet0/0/1] port default vlan 10
[SwitchA-GigabitEthernet0/0/1] quit
[SwitchA] interface gigabitethernet 0/0/2
[SwitchA-GigabitEthernet0/0/2] port link-type trunk
[SwitchA-GigabitEthernet0/0/2] port trunk allow-pass vlan 100
[SwitchA-GigabitEthernet0/0/2] quit
[SwitchA] interface gigabitethernet 0/0/3
[SwitchA-GigabitEthernet0/0/3] port link-type trunk
[SwitchA-GigabitEthernet0/0/3] port trunk allow-pass vlan 400
[SwitchA-GigabitEthernet0/0/3] quit
  •  2.配置各VLANIF接口的IP地址

  # 配置SwitchA。SwitchB、SwitchC和SwitchD的配置与SwitchA类似,不再赘述。

1
2
3
4
5
6
7
8
9
[SwitchA] interface vlanif 10
[SwitchA-Vlanif10] ip address 10.1.1.1 24
[SwitchA-Vlanif10] quit
[SwitchA] interface vlanif 100
[SwitchA-Vlanif100] ip address 192.168.12.1 24
[SwitchA-Vlanif100] quit
[SwitchA] interface vlanif 400
[SwitchA-Vlanif400] ip address 192.168.14.1 24
[SwitchA-Vlanif400] quit
  •  3.配置PC1–PC2的去程的静态路由

  # 配置SwitchA,配置两条等价的静态路由,下一跳分别指向SwitchB和SwitchD,这样就能实现去程的流量的负载分担。

1
2
[SwitchA] ip route-static 10.1.2.0 24 192.168.12.2
[SwitchA] ip route-static 10.1.2.0 24 192.168.14.2

   # 配置SwitchB。

1
[SwitchB] ip route-static 10.1.2.0 24 192.168.23.2

   # 配置SwitchD。

1
[SwitchD] ip route-static 10.1.2.0 24 192.168.34.1
  •  4.配置PC1–PC2的回程的静态路由

  # 配置SwitchC,配置两条等价的静态路由,下一跳分别指向SwitchB和SwitchD,这样就能实现回程流量的负载分担。

1
2
[SwitchC] ip route-static 10.1.1.0 24 192.168.23.1
[SwitchC] ip route-static 10.1.1.0 24 192.168.34.2

   # 配置SwitchB。

1
[SwitchB] ip route-static 10.1.1.0 24 192.168.12.1

   # 配置SwitchD。

1
[SwitchD] ip route-static 10.1.1.0 24 192.168.14.1
  •  5.配置主机

  配置主机PC1的IP地址为10.1.1.2/24,默认网关为10.1.1.1;配置主机PC2的IP地址为10.1.2.2,默认网关为10.1.2.1。

  • 6.验证配置结果

  #查看SwitchA的IP路由表。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[SwitchA] display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 9        Routes : 10      
 
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface
 
       10.1.1.0/24  Direct  0    0           D   10.1.1.1        Vlanif10
       10.1.1.1/32  Direct  0    0           D   127.0.0.1       Vlanif10
       10.1.2.0/24  Static  60   0          RD   192.168.12.2    Vlanif100
                    Static  60   0          RD   192.168.14.2    Vlanif400
      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.12.0/24  Direct  0    0           D   192.168.12.1    Vlanif100
   192.168.12.1/32  Direct  0    0           D   127.0.0.1       Vlanif100
   192.168.14.0/24  Direct  0    0           D   192.168.14.1    Vlanif400
   192.168.14.1/32  Direct  0    0           D   127.0.0.1       Vlanif400

   从SwitchA的IP路由表中可以看出,到达10.1.2.0/24这个网段有两条等价路由,这种情况下数据流将会平均分配到两条不同的链路上,即实现流量的负载分担。

 

posted @   讲文张字  阅读(1603)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
返回顶部
点击右上角即可分享
微信分享提示

喜欢请打赏

扫描二维码打赏

支付宝打赏