首页 > 代码库 > 静态路由的配置
静态路由的配置
实现PC1 与 PC2 的通信
R1:
Router>enable Router# Router#conf t Router(config)#inter f 0/0 Router(config-if)#ip address 192.168.10.254 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)# Router(config)#inter s 0/0/0 Router(config-if)#ip address 192.168.1.1 255.255.255.0 Router(config-if)#clock rate 64000 Router(config-if)#no shut Router(config-if)#exitetected at ‘^‘ marker. Router(config-if)#exit Router(config)# Router# Router#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set //两条直连路由 C 192.168.1.0/24 is directly connected, Serial0/0/0 C 192.168.10.0/24 is directly connected, FastEthernet0/0 Router#
R2:
Router>enable Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#inter f 0/0 Router(config-if)#ip address 192.168.20.254 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)# Router(config)#inter s 0/0/0 Router(config-if)#ip address 192.168.1.2 255.255.255.0 Router(config-if)#no shut Router(config-if)# Router(config-if)#exit Router(config)#end Router# Router#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set //两条直连路由 C 192.168.1.0/24 is directly connected, Serial0/0/0 C 192.168.20.0/24 is directly connected, FastEthernet0/0 Router#
PC 1 ping PC 2
Ping不通,目标主机不可达。路由器无法将192.168.10.0的数据包传送出去。
配置静态路由
R 1:
Router#conf t //配置静态路由,格式为: ip route 目的网段 子网掩码 吓一跳地址 Router(config)#ip route 192.168.20.0 255.255.255.0 192.168.1.2 Router(config)#exit Router# %SYS-5-CONFIG_I: Configured from console by console Router#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set C 192.168.1.0/24 is directly connected, Serial0/0/0 C 192.168.10.0/24 is directly connected, FastEthernet0/0 S 192.168.20.0/24 [1/0] via 192.168.1.2 //出现去往192.168.20.0的网络 Router#
R2:
Router(config)# Router(config)#ip route 192.168.10.0 255.255.255.0 192.168.1.1 Router(config)#end Router# %SYS-5-CONFIG_I: Configured from console by console Router#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set C 192.168.1.0/24 is directly connected, Serial0/0/0 S 192.168.10.0/24 [1/0] via 192.168.1.1 //有去往192.168.10.0的网络了 C 192.168.20.0/24 is directly connected, FastEthernet0/0 Router#
PC1 ping PC 2
PC 2 ping PC1
本文出自 “赵玉强的博客” 博客,请务必保留此出处http://zhaoyuqiang.blog.51cto.com/6328846/1581089
静态路由的配置
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。