show ip route可以说是网络工程师最常用的命令之一,对于查看路由指向、诊断网络问题很有帮助。对于一个大型网络,常常有成百数千条路由,如何才能找到自己需要的路由条目是一件很头疼的事情。
为了解决这个办法,我们常用show ip route | include +网络前缀 的方法来找到匹配的条目。
- 10.0.0.0/24 is subnetted, 11 subnets
- O 10.1.3.0 [110/20] via 10.1.1.1, 00:13:28, Ethernet0/0
- O 10.2.1.0 [110/20] via 10.1.1.1, 00:13:28, Ethernet0/0
- O 10.1.2.0 [110/20] via 10.1.1.1, 00:13:28, Ethernet0/0
- O 10.2.2.0 [110/20] via 10.1.1.1, 00:13:28, Ethernet0/0
- C 10.1.1.0 is directly connected, Ethernet0/0
- O 10.3.2.0 [110/20] via 10.1.1.1, 00:13:28, Ethernet0/0
- O 10.2.3.0 [110/20] via 10.1.1.1, 00:13:28, Ethernet0/0
- O 10.4.2.0 [110/20] via 10.1.1.1, 00:13:30, Ethernet0/0
- O 10.1.4.0 [110/20] via 10.1.1.1, 00:13:30, Ethernet0/0
- C 10.1.30.0 is directly connected, Ethernet0/0
- C 10.1.20.0 is directly connected, Ethernet0/0
- O 192.168.1.0/24 [110/20] via 10.1.1.1, 00:13:30, Ethernet0/0
- C 192.168.2.0/24 is directly connected, Ethernet0/0
- R2#show ip route | i 192.168.1
- O 192.168.1.0/24 [110/20] via 10.1.1.1, 00:15:46, Ethernet0/0
- R2#show ip route | i 10.1
- O 10.1.3.0 [110/20] via 10.1.1.1, 00:18:32, Ethernet0/0
- O 10.2.1.0 [110/20] via 10.1.1.1, 00:18:32, Ethernet0/0
- O 10.1.2.0 [110/20] via 10.1.1.1, 00:18:32, Ethernet0/0
- O 10.2.2.0 [110/20] via 10.1.1.1, 00:18:32, Ethernet0/0
- C 10.1.1.0 is directly connected, Ethernet0/0
- O 10.3.2.0 [110/20] via 10.1.1.1, 00:18:32, Ethernet0/0
- O 10.2.3.0 [110/20] via 10.1.1.1, 00:18:32, Ethernet0/0
- O 10.4.2.0 [110/20] via 10.1.1.1, 00:18:32, Ethernet0/0
- O 10.1.4.0 [110/20] via 10.1.1.1, 00:18:32, Ethernet0/0
- C 10.1.30.0 is directly connected, Ethernet0/0
- C 10.1.20.0 is directly connected, Ethernet0/0
- O 192.168.1.0/24 [110/20] via 10.1.1.1, 00:18:32, Ethernet0/0
- 10.0.0.0/24 is subnetted, 11 subnets
- O 10.1.3.0 [110/20] via 10.1.1.1, 00:21:16, Ethernet0/0
- O 10.1.2.0 [110/20] via 10.1.1.1, 00:21:16, Ethernet0/0
- C 10.1.1.0 is directly connected, Ethernet0/0
- O 10.1.4.0 [110/20] via 10.1.1.1, 00:21:16, Ethernet0/0
- C 10.1.30.0 is directly connected, Ethernet0/0
- C 10.1.20.0 is directly connected, Ethernet0/0
- R2(config)#access-list 1 per 10.1.0.0 0.0.255.255
- R2#sh ip route list 1
- O 10.1.3.0 [110/20] via 10.1.1.1, 00:35:15, Ethernet0/0
- O 10.1.2.0 [110/20] via 10.1.1.1, 00:35:15, Ethernet0/0
- C 10.1.1.0 is directly connected, Ethernet0/0
- O 10.1.4.0 [110/20] via 10.1.1.1, 00:35:15, Ethernet0/0
- C 10.1.30.0 is directly connected, Ethernet0/0
- C 10.1.20.0 is directly connected, Ethernet0/0
- 10.0.0.0/24 is subnetted, 11 subnets
- O 10.1.3.0 [110/20] via 10.1.1.1, 00:42:53, Ethernet0/0
- O 10.2.1.0 [110/20] via 10.1.1.1, 00:42:53, Ethernet0/0
- O 10.1.2.0 [110/20] via 10.1.1.1, 00:42:53, Ethernet0/0
- O 10.2.2.0 [110/20] via 10.1.1.1, 00:42:53, Ethernet0/0
- C 10.1.1.0 is directly connected, Ethernet0/0
- O 10.3.2.0 [110/20] via 10.1.1.1, 00:42:53, Ethernet0/0
- O 10.2.3.0 [110/20] via 10.1.1.1, 00:42:53, Ethernet0/0
- O 10.4.2.0 [110/20] via 10.1.1.1, 00:42:53, Ethernet0/0
- O 10.1.4.0 [110/20] via 10.1.1.1, 00:42:55, Ethernet0/0
- C 10.1.30.0 is directly connected, Ethernet0/0
- C 10.1.20.0 is directly connected, Ethernet0/0
- O 192.168.1.0/24 [110/20] via 10.1.1.1, 00:42:55, Ethernet0/0
- C 192.168.2.0/24 is directly connected, Ethernet0/0
- R2#sh ip route | i __10\.1\.
- O 10.1.3.0 [110/20] via 10.1.1.1, 00:46:29, Ethernet0/0
- O 10.1.2.0 [110/20] via 10.1.1.1, 00:46:29, Ethernet0/0
- C 10.1.1.0 is directly connected, Ethernet0/0
- O 10.1.4.0 [110/20] via 10.1.1.1, 00:46:29, Ethernet0/0
- C 10.1.30.0 is directly connected, Ethernet0/0
- C 10.1.20.0 is directly connected, Ethernet0/0
- R2#sh ip route | i __10\.(1|2)\.
- O 10.1.3.0 [110/20] via 10.1.1.1, 00:01:02, Ethernet0/0
- O 10.2.1.0 [110/20] via 10.1.1.1, 00:01:02, Ethernet0/0
- O 10.1.2.0 [110/20] via 10.1.1.1, 00:01:02, Ethernet0/0
- O 10.2.2.0 [110/20] via 10.1.1.1, 00:01:02, Ethernet0/0
- C 10.1.1.0 is directly connected, Ethernet0/0
- O 10.2.3.0 [110/20] via 10.1.1.1, 00:01:02, Ethernet0/0
- O 10.1.4.0 [110/20] via 10.1.1.1, 00:01:02, Ethernet0/0
- C 10.1.30.0 is directly connected, Ethernet0/0
- C 10.1.20.0 is directly connected, Ethernet0/0