系统城装机大师 - 固镇县祥瑞电脑科技销售部宣传站!

当前位置:首页 > 网络知识 > 路由器 > 详细页面

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

时间:2020-03-01来源:电脑系统城作者:电脑系统城

静态路由是一种需要管理员手工配置的特殊路由。静态路由比动态路由使用更少的带宽,并且不占用CPU资源来计算和更新路由。但是当网络发生故障或者拓扑发生变化后,静态路由不会自动更新,必须手动重新配置。静态路由有5个主要的参数:目的地址和掩码、出接口和下一跳、优先级。

使用静态路由的好处是配置简单、可控性高,当网络结构比较简单时,只需配置静态路由就可以使网络正常工作。在复杂网络环境中,还可以通过配置静态路由改进网络的性能,并且可以为重要的应用保证带宽。

配置注意事项

· 一般情况下两个设备之间的通信是双向的,因此路由也必须是双向的,在本端配置完静态路由以后,请不要忘记在对端设备上配置回程路由。

· 在企业网络双出口的场景中,通过配置两条等价的静态路由可以实现负载分担,流量可以均衡的分配到两条不同的链路上;通过配置两条不等价的静态路由可以实现主备份,当主用链路故障的时候流量切换到备用链路上。

组网需求

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

说明:

请确保该场景下互联接口的STP处于未使能状态。因为在使能STP的环形网络中,如果用交换机的VLANIF接口构建三层网络,会导致某个端口被阻塞,从而导致三层业务不能正常运行。

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

图1 配置静态路由实现路由负载分担组网图

配置思路

采用如下的思路配置静态路由实现路由负载分担:

  1. 创建VLAN并配置各接口所属VLAN,配置各VLANIF接口的IP地址。

  2. 配置数据流来回两个方向的静态路由。

  3. 在各主机上配置IP地址和默认网关。

操作步骤

  1. 配置各接口所属VLAN

配置SwitchA。SwitchB、SwitchC和SwitchD的配置与SwitchA类似。

<HUAWEI> system-view

[HUAWEI] sysnameSwitchA

[SwitchA] vlanbatch 10 100 400

[SwitchA] interfacegigabitethernet 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] interfacegigabitethernet 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] interfacegigabitethernet 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

  1. 配置各VLANIF接口的IP地址

配置SwitchA。SwitchB、SwitchC和SwitchD的配置与SwitchA类似。

[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] interfacevlanif 400

[SwitchA-Vlanif400]ip address 192.168.14.1 24

[SwitchA-Vlanif400]quit

  1. 配置PC1–PC2的去程的静态路由

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

[SwitchA] iproute-static 10.1.2.0 24 192.168.12.2

[SwitchA] iproute-static 10.1.2.0 24 192.168.14.2

配置SwitchB。

[SwitchB] iproute-static 10.1.2.0 24 192.168.23.2

配置SwitchD。

[SwitchD] iproute-static 10.1.2.0 24 192.168.34.1

  1. 配置PC1–PC2的回程的静态路由

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

[SwitchC] iproute-static 10.1.1.0 24 192.168.23.1

[SwitchC] iproute-static 10.1.1.0 24 192.168.34.2

配置SwitchB。

[SwitchB] iproute-static 10.1.1.0 24 192.168.12.1

配置SwitchD。

[SwitchD] iproute-static 10.1.1.0 24 192.168.14.1

  1. 配置主机

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

  1. 验证配置结果

#查看SwitchA的IP路由表。

[SwitchA] displayip 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这个网段有两条等价路由,这种情况下数据流将会平均分配到两条不同的链路上,即实现流量的负载分担。

配置文件

· SwitchA的配置文件

#

sysname SwitchA

#

vlan batch 10 100400

#

interface Vlanif10

ip address 10.1.1.1 255.255.255.0

#

interface Vlanif100

ip address 192.168.12.1 255.255.255.0

#

interface Vlanif400

ip address 192.168.14.1 255.255.255.0

#

interface GigabitEthernet0/0/1

port link-type access

port default vlan 10

#

interface GigabitEthernet0/0/2

port link-type trunk

port trunk allow-pass vlan 100

#

interface GigabitEthernet0/0/3

port link-type trunk

port trunk allow-pass vlan 400

#

ip route-static10.1.2.0 255.255.255.0 192.168.12.2

ip route-static10.1.2.0 255.255.255.0 192.168.14.2

#

return

· SwitchB的配置文件

#

sysname SwitchB

#

vlan batch 100 200

#

interface Vlanif100

ip address 192.168.12.2 255.255.255.0

#

interface Vlanif200

ip address 192.168.23.1 255.255.255.0

#

interface GigabitEthernet0/0/1

port link-type trunk

port trunk allow-pass vlan 100

#

interface GigabitEthernet0/0/2

port link-type trunk

port trunk allow-pass vlan 200

#

ip route-static10.1.1.0 255.255.255.0 192.168.12.1

ip route-static10.1.2.0 255.255.255.0 192.168.23.2

#

return

· SwitchC的配置文件

#

sysname SwitchC

#

vlan batch 20 200300

#

interface Vlanif20

ip address 10.1.2.1 255.255.255.0

#

interface Vlanif200

ip address 192.168.23.2 255.255.255.0

#

interface Vlanif300

ip address 192.168.34.1 255.255.255.0

#

interface GigabitEthernet0/0/1

port link-type access

port default vlan 20

#

interface GigabitEthernet0/0/2

port link-type trunk

port trunk allow-pass vlan 200

#

interface GigabitEthernet0/0/3

port link-type trunk

port trunk allow-pass vlan 300

#

ip route-static10.1.1.0 255.255.255.0 192.168.23.1

ip route-static10.1.1.0 255.255.255.0 192.168.34.2

#

return

· SwitchD的配置文件

#

sysname SwitchD

#

vlan batch 300 400

#

interface Vlanif300

ip address 192.168.34.2 255.255.255.0

#

interface Vlanif400

ip address 192.168.14.2 255.255.255.0

#

interface GigabitEthernet0/0/1

port link-type trunk

port trunk allow-pass vlan 400

#

interface GigabitEthernet0/0/2

port link-type trunk

port trunk allow-pass vlan 300

#

ip route-static10.1.1.0 255.255.255.0 192.168.14.1

ip route-static10.1.2.0 255.255.255.0 192.168.34.1

#

return

分享到:

相关信息

系统教程栏目

栏目热门教程

人气教程排行

站长推荐

热门系统下载