实现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
时间: 2024-11-05 16:09:17