Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#interface FastEthernet0/0 Router(config-if)#ip address 192.168.1.1 255.255.255.0 Router(config-if)#no shutdown Router(config-if)#exit Router(config)#interface Serial2/0 Router(config-if)#ip address 192.168.3.1 255.255.255.0 Router(config-if)#no shutdown
配置r1
1 2 3 4 5 6 7 8 9 10
Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#interface FastEthernet0/0 Router(config-if)#ip address 192.168.2.1 255.255.255.0 Router(config-if)#no shutdown Router(config-if)#exit Router(config)#interface Serial2/0 Router(config-if)#ip address 192.168.3.2 255.255.255.0 Router(config-if)#no shutdown
配置r0和r1的静态路由
手动在r0上指定pc1所在的网段(192.168.2.0/24)在端口Serial2/0
1
ip route 192.168.2.0 255.255.255.0 Serial2/0
同理, 在r1配置
1
ip route 192.168.1.0 255.255.255.0 Serial2/0
配置完成后查看路由表:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
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, FastEthernet0/0 S 192.168.2.0/24 is directly connected, Serial2/0 C 192.168.3.0/24 is directly connected, Serial2/0
测试
完成后分别在r0和pc0上测试ping pc1
1 2 3 4 5 6
Router#ping 192.168.2.2
Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.2.2, timeout is2 seconds: !!!!! Success rate is100 percent (5/5), round-trip min/avg/max = 1/10/23 ms
Ping statistics for192.168.2.2: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 1ms, Maximum = 6ms, Average = 2ms