第五章IP 路由 5.1. 查找路由条目 提问 在路由表中查找特定的路由条目 回答 Router>show ip route 172.25.100.15 Routing entry for 172.25.100.0/24 Known via "ospf 55", distance 110, metric 11, type inter area Redistributing via ospf 55 Last update from 172.25.1.1 on Ethernet0, 2d12h ago Routing Descriptor Blocks: * 172.25.1.1, from 172.25.1.1, 2d12h ago, via Ethernet0 Route metric is 11, traffic share count is 1 注释 路由器在路由表中查找路由条目的原则是最长匹配,所以例子中虽然查找的是172.25.200.15 但是由于没有这条特定的路由,显示的结果是最长匹配的172.15.100.0/24。如果没有任何一条匹配只能使用缺省路由,会出现下面信息 Router> show ip route 172.15.101.5 % Network not in table 注意的是这里都是无类路由,如果有类的就不一样了 5.2. 查找特定类型的路由条目 提问 在路由表中查找相同类型的路由条目 回答 Router>show ip route static 192.168.1.0/32 is subnetted, 1 subnets S 192.168.1.1 [1/0] via 172.25.1.4 还有一个更有用的命令 Router>show ip route summary IP routing table name is Default-IP-Routing-Table(0) Route Source Networks Subnets Overhead Memory (bytes) connected 0 3 328 432 static 1 0 64 144 ospf 55 1 3 256 576 Intra-area: 1 Inter-area: 2 External-1: 1 External-2: 0 NSSA External-1: 0 NSSA External-2: 0 internal 2 2328 Total 4 6 648 3480 注释 通过显示路由表的统计情况来了解当前路由器的路由条目,也可以用来以后的比对 5.3. 各种掩码的转换 注释 脚本略去,建议使用Boson 提供的免费转换工具 5.4. 使用静态路由 提问 配置静态路由 回答 Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#ip route 10.35.15.5 255.255.255.255 Ethernet0 (permanent 选项可以使此条目一直存在于路由表中,而不管下一跳的可达性) Router(config)#ip route 172.16.0.0 255.255.0.0 10.35.6.1 2 (permanent) Router(config)#end Router# 也可以给路由条目打上标签 Router#configure terminal Enter conf...