Cisco IOS Cookbook 中文精简版第五章IP路由

来源: 作者: 2007-03-17 出处:pcdog.com

access  cisco  cisco ios  ospf  xml  
下一页 1 2 3 

<!--[if !supportLists]-->第五章    <!--[endif]-->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 configuration commands, one per line.  End with CNTL/Z.

Router(config)#ip route 172.16.0.0 255.255.0.0 10.35.6.1 2 tag 36291

Router(config)#end

Router#

 

注释 在类似以太网这种多路访问的网络中建议使用下一跳为地址而不是接口。正常情况下路由器对静态路由的下一跳有效性的检查是一分钟,在12.3(10)以后增加了下面的命令可以对此时间进行调整Router(config)#ip route static adjust-time 30对静态路由打tag用于路由再发布时的区分

5.5.  浮动静态路由

提问 动态路由出问题的时候使用静态路由作为备份

回答

Router#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#ip route 10.0.0.0 255.0.0.0 172.16.1.1 190  (下一跳也可以触发一个拨号接口)

Router(config)#end

Router#

 

注释 通过调整管理距离的方式来进行路由备份,不过要注意的是管理距离只适合在相同路由的情况下,路由条目的最长匹配是第一位的。另外在不同厂商设备互联的时候,调整管理距离一定要设置合理。

5.6.  基于源地址的策略路由

提问 根据源地址的不同选择不同的路径

回答

Router#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#access-list 1 permit 10.15.35.0 0.0.0.255

Router(config)#access-list 2 permit 10.15.36.0 0.0.0.255

Router(config)#interface Ethernet0

Router(config-if)#ip address 10.15.22.7 255.255.255.0

Router(config-if)#ip policy route-map Engineers

Router(config-if)#ip route-cache policy

Router(config-if)#exit

Router(config)#route-map Engineers permit 10

Router(config-route-map)#match ip address 1

Router(config-route-map)#set ip next-hop 10.15.27.1

Router(config-route-map)#exit

Router(config)#route-map Engineers permit 20

Router(config-route-map)#match ip address 2

Router(config-route-map)#set interface Ethernet1

Router(config-route-map)#end

Router#

注释 缺省情况下route map的最后一句都是deny all,这样不符合route map规则的数据包都会按照正常的路由表进行转发。set ip next-hop verify-availability命令提供了对下一跳的验证,不过是基于CDP的,所以如果使用此命令需要打开CDP,最好同时调整时长,毕竟缺省是180秒。在使用策略路由时会在排错时增加难度,因为缺省对于本路由器发出的数据包可以绕过route map这样会造成错觉。


更多内容请看PCdog.com--Cisco IOS技术手册  Cisco交换机  Cisco路由器配置手册专题
下一页 1 2 3 
上一篇:Cisco IOS Cookbook 中文精简版第四章TACAS+
下一篇:Cisco IOS Cookbook 中文精简版第六章RIP