静态路由,无需消耗网络设备的CPU的资源来计算分析,但是静态路由需要网络管理员手动配置和维护,同时静态路由不能动态根据网络拓扑的改变而改变。
静态路由格式:[***]ip route-static 目标网段 目标网段掩码 下一跳ip地址
根据直连路由的情况可知,数据不能全网互通,是因为路由表中缺少路由信息,通过配置静态路由或者动态路由就可以实现互通。‘
配置静态路由,要清楚目标网段以及下一跳地址,在路由器的系统模式下进行配置。
dis ip routing-table #查看路由信息检查配置正确
拓扑图如下:
通过路由器配置ip地址以及静态路由,实现各个网段之间网络互通,各个设备之间可以互通,网络通信正常。
AR1静态路由配置:
<AR1>sys
System View: return to User View with Ctrl+Z.
[AR1]ip route-static 20.20.20.2 32 192.168.10.2
[AR1]ip route-static 192.168.20.0 24 192.168.10.2
[AR1]ip route-static 30.30.30.3 32 192.168.10.2
[AR1]ip route-static 192.168.40.0 24 192.168.10.2
[AR1]quit
<AR1>save
The current configuration will be written to the device. Are you sure? [Y/N]:Y
Please input the file name(*.cfg)[flash:/startup.cfg]
(To leave the existing filename unchanged, press the enter key):
flash:/startup.cfg exists, overwrite? [Y/N]:Y
Validating file. Please wait...
Configuration is saved to device successfully.
<AR1>
AR2静态路由配置:
[AR2]ip route-static 192.168.30.0 24 192.168.10.1
[AR2]ip route-static 10.10.10.1 32 192.168.10.1
[AR2]ip route-static 30.30.30.3 32 192.168.20.3
[AR2]ip route-static 192.168.40.0 24 192.168.20.3
[AR2]quit
<AR2>save
The current configuration will be written to the device. Are you sure? [Y/N]:Y
Please input the file name(*.cfg)[flash:/startup.cfg]
(To leave the existing filename unchanged, press the enter key):
flash:/startup.cfg exists, overwrite? [Y/N]:Y
Validating file. Please wait...
Configuration is saved to device successfully.
<AR2>
AR3静态路由配置:
<AR3>sys
System View: return to User View with Ctrl+Z.
[AR3]ip route-static 192.168.10.0 24 192.168.20.2
[AR3]ip route-static 192.168.30.0 24 192.168.20.2
[AR3]ip route-static 20.20.20.2 32 192.168.20.2
[AR3]ip route-static 10.10.10.1 32 192.168.20.2
[AR3]quit
<AR3>save
The current configuration will be written to the device. Are you sure? [Y/N]:Y
Please input the file name(*.cfg)[flash:/startup.cfg]
(To leave the existing filename unchanged, press the enter key):
flash:/startup.cfg exists, overwrite? [Y/N]:Y
Validating file. Please wait...
Configuration is saved to device successfully.
<AR3>
测试通信 PC1 ping PC2,以上配置之后形成了完整的路由实现了网络互通
路由信息:
AR1:
直连路由条目:10.10.10.1/32、192.168.10.0/24、192.168.30.0/24
静态路由条目:20.20.20.2/32、30.30.30.3/32、192.168.20.0/24、192.168.40.0/24
AR2:
直连路由条目:20.20.20.1/32、192.168.10.0/24/192.168.20.0/24
静态路由条目:10.10.10.1/32、30.30.30.3/32、192.168.30.0/24、192.168.40.0/24
AR3:
直连路由条目:20.20.20.1/32、192.168.20.0/24、192.168.40.0/24
静态路由条目:10.10.10.1/32、20.20.20.2/32、192.168.10.0/24、192.168.30.0/24