任务 2:观察默认情况下的路由表
步骤 1:在 R1 上创建 Loopback0 接口,IP 为 192.168.1.1/24,模拟 R1 连接着一个 192.168.1.0/24 的局域网 R1(config)#interface loopback 0
R1(config)#interface loopback 0 R1(config-if)#ip address 192.168.1.1 255.255.255.0 R1(config-if)#exit
步骤 2:使用 show ip route 命令检查 R1 的路由表,发现 R1 的路由表中只有直连网络的路 由,分别是 192.168.1.0/24(Loopback0)和 192.168.12.0/24(连接 R2 的 Fa0/0.12)
R1#show ip route Codes: C - connected, S - static, 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 i - IS-IS, su - IS-IS summary, 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.12.0/24 is directly connected, FastEthernet0/0.12 C 192.168.1.0/24 is directly connected, Loopback0
步骤 3:在 R3 上增加 Loopback0 接口,IP 为 192.168.3.1/24,模拟 R3 连接着一个 192.168.3.0/24 的局域网 R3(config)#interface loopback 0
R3(config)#interface loopback 0 R3(config-if)#ip address 192.168.3.1 255.255.255.0 R3(config-if)#exit
步骤 4:检查 R3 的路由表,只能看到 192.168.3.0/24 和 192.168.23.0/24,这两个网段是 R3 的直连网络
R3#show ip route Codes: C - connected, S - static, 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 i - IS-IS, su - IS-IS summary, 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.23.0/24 is directly connected, FastEthernet0/0.23 C 192.168.3.0/24 is directly connected, Loopback0
步骤 5:在 R4 上增加 Loopback0,IP 为 192.168.4.1/24,模拟 R4 连接着一个 192.168.4.0/24 的局域网
R4(config)#interface loopback 0 R4(config-if)#ip address 192.168.4.1 255.255.255.0 R4(config-if)#exit
步骤 6:检查 R4 的路由表,只能看到 192.168.4.0/24 和 192.168.24.0/24,这两个网段是 R4 的直连网络
R4#show ip route Codes: C - connected, S - static, 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 i - IS-IS, su - IS-IS summary, 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.24.0/24 is directly connected, FastEthernet0/0.24 C 192.168.4.0/24 is directly connected, Loopback0
步骤 7:检查 R2 的路由表,发现现在只有 192.168.12.0/24、192.168.23.0/24 和 192.168.24.0/24,这 3 个网段都是 R2 的直连网络
R2#show ip route Codes: C - connected, S - static, 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 i - IS-IS, su - IS-IS summary, 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.12.0/24 is directly connected, FastEthernet0/0.12 C 192.168.24.0/24 is directly connected, FastEthernet0/0.24 C 192.168.23.0/24 is directly connected, FastEthernet0/0.23
由此可见,路由器的路由表中默认只有直连网络的路由条目
步骤 8:使用 ping 测试,发现任何一台路由器都只能 ping 通自己的接口和自己链路对面的 接口,比如 R1,只能 ping 通 192.168.1.1(自己)、192.168.12.1(自己的 Fa0/0.12)和 192.168.12.2(自己 Fa0/0.12 对面的接口),而除此之外的其他 IP 是无法 ping 通的
R1#ping 192.168.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 4/5/8 ms
R1#ping 192.168.12.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.12.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 4/5/8 ms
R1#ping 192.168.12.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.12.2, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 20/32/44 ms
R1#ping 192.168.23.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.23.2, timeout is 2 seconds: ..... Success rate is 0 percent (0/5)