路由器静态路由配置命令(1)


1. ip route

配置或删除静态路由。

[ no ] ip route ip-address { mask | mask-length } { interfacce-name | gateway-address } [ preference preference-value ] [ reject | blackhole ]

参数说明】

ip-address和mask为目的IP地址和掩码,点分十进制格式,由于要求掩码32位中‘1’必须是连续的,因此点分十进制格式的掩码可以用掩码长度mask-length来代替,掩码长度为掩码中连续‘1’的位数。

interfacce-name指定该路由的发送接口名,gateway-address为该路由的下一跳IP地址点分十进制格式)。

preference-value为该路由的优先级别,范围0~255。

reject指明为不可达路由。

blackhole指明为黑洞路由。
缺省情况】

系统缺省可以获取到去往与路由器相连子网的子网路由。在配置静态路由时如果不指定优先级,则缺省为60。如果没有指明reject或blackhole,则缺省为可达路由。

命令模式】

全局配置模式

使用指南】

配置静态路由的注意事项:

当目的IP地址和掩码均为0.0.0.0时,配置的缺省路由,即当查找路由表失败后,根据缺省路由进行包的转发。

对优先级的不同配置,可以灵活应用路由管理策略,如配置到达相同目的地的多条路由,如果指定相同优先级,则可实现负载分担;如果指定不同优先级,则可实现路由备份。

在配置静态路由时,既可指定发送接口,也可指定下一跳地址,到底采用哪种方法,需要根据实际情况而定:对于支持网络地址到链路层地址解析的接口或点到点接口,指定发送接口即可;对于NBMA接口,如封装X.25或帧中继的接口、拨号口等,支持点到多点,这时除了配置IP路由外,还需在链路层建立二次路由,即IP地址到链路层地址的映射如dialer map ip、x.25 map ip或frame-relay map ip等),这种情? 配置静态路由不能指定发送接口,应配置下一跳IP地址。

举例】

配置缺省路由的下一跳为129.102.0.2。

Quidway(config)#ip route 0.0.0.0 0.0.0.0 129.102.0.2

相关命令】

show ip route,show ip route detail,show ip route static

2.show ip route

显示路由表摘要信息。

show ip route

命令模式】

特权用户模式

使用指南】

该命令输出以列表方式显示路由表,每一行代表一条路由,内容包括:

目的地址/掩码长度
协议
优先级
度量值
下一跳
输出接口
举例】

Quidway#show ip route 
Routing Tables:
Destination/Mask Proto Pref Metric Nexthop Interface
127.0.0.0/8 Static 0 0 127.0.0.1 127.0.0.1(LO0)
127.0.0.1/32 Direct 0 0 127.0.0.1 127.0.0.1(LO0)
138.102.128.0/17 Direct 0 0 138.102.129.7 138.102.129.7(EN0)
202.38.165.0/24 Direct 0 0 202.38.165.1 202.38.165.1(SL1)

相关命令】

ip route,show ip route detail,show ip route static

3. show ip route detail
显示路由表详细信息

show ip route detail

命令模式】

特权用户模式

使用指南】

该命令输出信息帮助用户进行路由方面的故障诊断。

举例】

Quidway#show ip route detail 
Route state description
NoAdv: do not advertiset Int: AS Interior route
Ext: AS External route Del: route to be deleted
Active: current route Retain: route retains in the routing table
Rej: rejecting route Black: black hole route
Routing Tables:
Generate Default: no
+ = Active Route, - = Last Active, * = Both
Destinations: 4 Routes: 4
Holddown: 0 Delete: 9 Hidden: 0
**Destination: 127.0.0.0 Mask: 255.0.0.0
Protocol: *Static Preference: 0
NextHop: 127.0.0.1 Interface: 127.0.0.1(LO0)
State: $#@60;NoAdv Int Active Retain Rej$#@62;
Age: 19:31:06 Metric: 0/0
**Destination: 127.0.0.1 Mask: 255.255.255.255
Protocol: *Direct Preference: 0
NextHop: 127.0.0.1 Interface: 127.0.0.1(LO0)
State: $#@60;NoAdv Int Active Retain$#@62;
Age: 114:03:05 Metric: 0/0


相关内容