昆仑山

首页 » 问答 » 类别 » 详解不同网段VLAN通过静态路由实现
TUhjnbcbe - 2024/6/4 19:13:00

组网要求:某公司有三台属于不同网段(Vlan)的主机通过三台交换机相连,要求不配置动态路由协议,使不同网段的任意两台主机之间能够互通。

一、本节主要知识点:

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

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

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

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

二、配置思路:

1.创建VLAN并配置各接口所属VLAN,配置各VLANIF接口的IP地址,实现相邻设备

网络互通。

2.在各主机上配置IP缺省网关,在各台Switch上配置IPv4静态路由或者静态缺省路由,实现不配置动态路由协议,使不同网段的任意两台主机之间能够互通。

三、IP设置:

1、SW1:VLANif10:..10./24,vlan10

VLANif20:..20.1/24,vlan20

PC1:..10.1/24

2、SW2:VLANif20:..20.2/24

VLANif30:..30./24,vlan30

VLANif40:..40.1/24

PC2:..30.1/24

3、SW3:VLANif40:..40.2/24

VLANif50:..50./24,vlan50

PC3:..50.1/24

四、实际操作视频:

15:41

五、SW1交换机的主要配置文件:

#

sysnameSW1

#

vlanbatch

#

interfaceVlanif10

ipaddress..10....0

#

interfaceVlanif20

ipaddress..20.1...0

#

interfaceMEth0/0/1

#

interfaceGigabitEthernet0/0/1

portlink-typeaccess

portdefaultvlan10

#

interfaceGigabitEthernet0/0/2

portlink-typetrunk

porttrunkallow-passvlan2to

#

iproute-static0.0.0.00.0.0.0..20.2

#

return

六、SW2交换机的主要配置文件:

#

sysnameSW2

#

vlanbatch

#

interfaceVlanif20

ipaddress..20.2...0

#

interfaceVlanif30

ipaddress..30....0

#

interfaceVlanif40

ipaddress..40.1...0

#

interfaceMEth0/0/1

#

interfaceGigabitEthernet0/0/1

portlink-typetrunk

porttrunkallow-passvlan2to

#

interfaceGigabitEthernet0/0/2

portlink-typetrunk

porttrunkallow-passvlan2to

#

interfaceGigabitEthernet0/0/3

portlink-typeaccess

portdefaultvlan30

#

iproute-static..10.0...0..20.1

iproute-static..50.0...0..40.2

#

return

七、SW3交换机的主要配置文件:

#

sysnameSW3

#

vlanbatch

#

interfaceVlanif40

ipaddress..40.2...0

#

interfaceVlanif50

ipaddress..50....0

#

interfaceMEth0/0/1

#

interfaceGigabitEthernet0/0/1

portlink-typeaccess

portdefaultvlan50

#

interfaceGigabitEthernet0/0/2

portlink-typetrunk

porttrunkallow-passvlan2to

#

iproute-static0.0.0.00.0.0.0..40.1

#

return

八、验证配置结果:

1、查看SW1的IP路由表。

[SW1]dispiprouting-table

RouteFlags:R-relay,D-downloadtofib

------------------------------------------------------------------------------

RoutingTables:Public

Destinations:7Routes:7

Destination/MaskProtoPreCostFlagsNextHopInterface

0.0.0.0/0StaticRD..20.2Vlanif20

.0.0.0/8Direct00D.0.0.1InLoopBack0

.0.0.1/32Direct00D.0.0.1InLoopBack0

..10.0/24Direct00D..10.Vlanif10

..10./32Direct00D.0.0.1Vlanif10

..20.0/24Direct00D..20.1Vlanif20

..20.1/32Direct00D.0.0.1

2、查看SW2的IP路由表。

[SW2]dispiprouting-table

RouteFlags:R-relay,D-downloadtofib

------------------------------------------------------------------------------

RoutingTables:Public

Destinations:10Routes:10

Destination/MaskProtoPreCostFlagsNextHopInterface

.0.0.0/8Direct00D.0.0.1InLoopBack0

.0.0.1/32Direct00D.0.0.1InLoopBack0

..10.0/24StaticRD..20.1Vlanif20

..20.0/24Direct00D..20.2Vlanif20

..20.2/32Direct00D.0.0.1Vlanif20

..30.0/24Direct00D..30.Vlanif30

..30./32Direct00D.0.0.1Vlanif30

..40.0/24Direct00D..40.1Vlanif40

..40.1/32Direct00D.0.0.1Vlanif40

..50.0/24StaticRD..40.2

3、在PC1上使用ping命令验证连通性。

PCping..50.1

Ping..50.1:32databytes,PressCtrl_Ctobreak

From..50.1:bytes=32seq=1ttl=time=47ms

From..50.1:bytes=32seq=2ttl=time=78ms

---..50.1pingstatistics---

2packet(s)transmitted

2packet(s)received

0.00%packetloss

round-tripmin/avg/max=47/62/78ms

3、在pc1上使用Tracert命令验证连通性。

PCtracert..50.1

tracerouteto..50.1,8hopsmax

(ICMP),pressCtrl+Ctostop

1..10.16ms15ms32ms

2..20.ms47ms62ms

3..40.ms63ms62ms

4..50.ms63ms94ms

1
查看完整版本: 详解不同网段VLAN通过静态路由实现