组网要求:某公司有三台属于不同网段(Vlan)的主机通过三台交换机相连,要求不配置动态路由协议,使不同网段的任意两台主机之间能够互通。
视频加载中…
一、本节主要知识点:
静态路由:静态路由是一种需要管理员手工配置的特殊路由。静态路由比动态路由使用更少的带宽,并且不占用CPU资源来计算和分析路由更新。但是当网络发生故障或者拓扑发生变化后,静态路由不会自动更新,必须手动重新配置。静态路由有5个主要的参数:目的地址和掩码、出接口和下一跳、优先级。
使用静态路由的好处是配置简单、可控性高,当网络结构比较简单时,只需配置静态路由就可以使网络正常工作。在复杂网络环境中,还可以通过配置静态路由改进网络的性能,并且可以为重要的应用保证带宽。
注意事项:一般情况下两个设备之间的通信是双向的,因此路由也必须是双向的,在本端配置完静态路由以后,请不要忘记在对端设备上配置回程路由。
在企业网络双出口的场景中,通过配置两条等价的静态路由可以实现负载分担,流量可以均衡地分配到两条不同的链路上;通过配置两条不等价的静态路由可以实现主备份,当主用链路故障的时候流量切换到备用链路上。
二、配置思路:
1. 创建VLAN并配置各接口所属VLAN,配置各VLANIF接口的IP地址,实现相邻设备
网络互通。
2. 在各主机上配置IP缺省网关,在各台Switch上配置IPv4静态路由或者静态缺省路由,实现不配置动态路由协议,使不同网段的任意两台主机之间能够互通。
三、IP设置:
1、SW1:VLANif10:192.168.10.254/24 ,vlan10
VLANif20:192.168.20.1/24 ,vlan20
PC1:192.168.10.1/24
2、SW2:VLANif20:192.168.20.2/24
VLANif30:192.168.30.254/24 ,vlan30
VLANif40:192.168.40.1/24
PC2:192.168.30.1/24
3、SW3:VLANif40:192.168.40.2/24
VLANif50:192.168.50.254/24 ,vlan 50
PC3:192.168.50.1/24
四、SW1交换机的主要配置文件:
#
sysname SW1
#
vlan batch 10 20
#
interface Vlanif10
ip address 192.168.10.254 255.255.255.0
#
interface Vlanif20
ip address 192.168.20.1 255.255.255.0
#
interface MEth0/0/1
#
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 2 to 4094
#
ip route-static 0.0.0.0 0.0.0.0 192.168.20.2
#
return
五、SW2交换机的主要配置文件:
#
sysname SW2
#
vlan batch 20 30 40
#
interface Vlanif20
ip address 192.168.20.2 255.255.255.0
#
interface Vlanif30
ip address 192.168.30.254 255.255.255.0
#
interface Vlanif40
ip address 192.168.40.1 255.255.255.0
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
interface GigabitEthernet0/0/3
port link-type access
port default vlan 30
#
ip route-static 192.168.10.0 255.255.255.0 192.168.20.1
ip route-static 192.168.50.0 255.255.255.0 192.168.40.2
#
return
六、SW3交换机的主要配置文件:
#
sysname SW3
#
vlan batch 40 50
#
interface Vlanif40
ip address 192.168.40.2 255.255.255.0
#
interface Vlanif50
ip address 192.168.50.254 255.255.255.0
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1
port link-type access
port default vlan 50
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
ip route-static 0.0.0.0 0.0.0.0 192.168.40.1
#
return
七、验证配置结果:
1、查看SW1的IP路由表。
[SW1]disp ip routing-table
Route Flags: R – relay, D – download to fib
——————————————————————————
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 Static 60 0 RD 192.168.20.2 Vlanif20
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.10.0/24 Direct 0 0 D 192.168.10.254 Vlanif10
192.168.10.254/32 Direct 0 0 D 127.0.0.1 Vlanif10
192.168.20.0/24 Direct 0 0 D 192.168.20.1 Vlanif20
192.168.20.1/32 Direct 0 0 D 127.0.0.1
2、查看SW2的IP路由表。
[SW2]disp ip routing-table
Route Flags: R – relay, D – download to fib
——————————————————————————
Routing Tables: Public
Destinations : 10 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
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.10.0/24 Static 60 0 RD 192.168.20.1 Vlanif20
192.168.20.0/24 Direct 0 0 D 192.168.20.2 Vlanif20
192.168.20.2/32 Direct 0 0 D 127.0.0.1 Vlanif20
192.168.30.0/24 Direct 0 0 D 192.168.30.254 Vlanif30
192.168.30.254/32 Direct 0 0 D 127.0.0.1 Vlanif30
192.168.40.0/24 Direct 0 0 D 192.168.40.1 Vlanif40
192.168.40.1/32 Direct 0 0 D 127.0.0.1 Vlanif40
192.168.50.0/24 Static 60 0 RD 192.168.40.2
3、在PC1上使用ping命令验证连通性。
PC>ping 192.168.50.1
Ping 192.168.50.1: 32 data bytes, Press Ctrl_C to break
From 192.168.50.1: bytes=32 seq=1 ttl=125 time=47 ms
From 192.168.50.1: bytes=32 seq=2 ttl=125 time=78 ms
— 192.168.50.1 ping statistics —
2 packet(s) transmitted
2 packet(s) received
0.00% packet loss
round-trip min/avg/max = 47/62/78 ms
3、在pc1上使用Tracert命令验证连通性。
PC>tracert 192.168.50.1
traceroute to 192.168.50.1, 8 hops max
(ICMP), press Ctrl+C to stop
1 192.168.10.254 16 ms 15 ms 32 ms
2 192.168.20.2 31 ms 47 ms 62 ms
3 192.168.40.2 78 ms 63 ms 62 ms
4 192.168.50.1 78 ms 63 ms 94 ms