Router0配置代码:
##端口配置
Router(config)#int fastEthernet 0/0
Router(config-if)#ip address 192.168.10.254 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#int fastEthernet 0/1
Router(config-if)#ip address 192.168.20.1 255.255.255.252
Router(config-if)#no shutdown
Router(config-if)#exit
##静态路由配置:目的网段 子网掩码 下一跳
Router(config)#ip route 192.168.30.0 255.255.255.252 192.168.20.2
Router(config)#ip route 192.168.40.0 255.255.255.0 192.168.20.2
下一跳IP为本路由器对端路由器的直连端口IP地址
Router1配置代码:
##同Router0
Router(config)#int fastEthernet 0/0
Router(config-if)#ip address 192.168.20.2 255.255.255.252
Router(config-if)#no shutdown
Router(config-if)#int fastEthernet 0/1
Router(config-if)#ip address 192.168.30.1 255.255.255.252
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#ip route 192.168.10.0 255.255.255.0 192.168.20.1
Router(config)#ip route 192.168.40.0 255.255.255.0 192.168.30.2
Router2配置代码:
##同Router0
Router(config)#int fastEthernet 0/0
Router(config-if)#ip address 192.168.30.2 255.255.255.252
Router(config-if)#no shutdown
Router(config-if)#int fastEthernet 0/1
Router(config-if)#ip address 192.168.40.254 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#ip route 192.168.10.0 255.255.255.0 192.168.30.1
Router(config)#ip route 192.168.20.0 255.255.255.252 192.168.30.1
测试:PC0 ping PC1 作者:野生网工技术宅 https://www.bilibili.com/read/cv23208432 出处:bilibili