思科静态路由配置命令 静态路由配置命令

一、实战要求
1. 设置路由器的基本参数 , 图配置完成后应保证在cisco2上可以ping 通cisco1和 cisco3 。
2. 在路由器cisco1配置静态路由(使用本地出站接口);
3. 在cisco3上配置默认路由(使用邻居路由器的下一跳地址);
二、拓扑

思科静态路由配置命令 静态路由配置命令


三、步骤
1. 检验路由器之间的三层连通性
cisco2#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 = 32/55/80 ms
cisco2#ping 192.168.23.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.23.3,timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/61/120 ms
cisco2#
2、 在cisco1上配置静态路由
cisco1#ping 192.168.23.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.23.3,timeout is 2 seconds:
…..
注:Ping不成功 , 原因是路由表中没有到达192.168.23.0网段的信息
cisco1#show ip route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial0
注:C代表的是直连网段 , 而我们需要配置和学习的是非直连网段
cisco1(config)#ip route 192.168.23.0 255.255.255.0 192.168.12.2
注:上面所加的ip地址分别为目的网段、子网掩码、下一跳地址
cisco1#sh ip route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial0
S 192.168.23.0/24 [1/0] via 192.168.1.2
注:S代表静态路由、管理距离值为1、度量值为0 。
cisco1#ping 192.168.23.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.23.3,timeout is 2 seconds:
…..
问题分析:虽然现在路由表中有路由条目了 , 但是ping却没有成功 , 那是因为我们的PING命令是基于ICMP协议 , ping到对方的时候 , 我们使用的是ECHO REQUEST报文 , 对方收到后 , 我们使用的是ECHO RELAY来回应 , 那么现在只有cisco1 上路由条目 , 而cisco3上却没有回来的路径 , 所以ping会失败 。
cisco3#sh ip route
Gateway of last resort is not set
C 192.168.23.0/24 is directly connected, Serial1
cisco1#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:
!!!!!
cisco2#sh ip route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial0
C 192.168.23.0/24 is directly connected, Serial1
问题分析:这个时候我们发现在cisco2上的路由条目中有2个直连网段的条目 , 当我们从cisco1 ping到cisco2上的时候 , cisco2上可以利用直连路由到达192.168.12.1这个接口IP地址 。从而说明 , 路由器需要学习的是非直连网段的路由条目 。为了让cisco1能ping到cisco3 , 我们还需要以下的设置 。
cisco3(config)#ip route 192.168.12.0 255.255.255.0 serial 1
注:除了可以用下一跳地址 , 还可以用出站接口的名称 。【点都点串行链路可以使用出接口】
cisco3(config)#end
cisco3#sh ip route
Gateway of last resort is not set
S 192.168.12.0/24 is directly connected, Serial1
注:使用本地出站接口的静态路由 , 它就好像是直连在路由器的接口上的 , 所以它的管理距离值为0
C 192.168.23.0/24 is directly connected, Serial1
cisco3#ping 192.168.12.1
Type escape sequence to abort.

推荐阅读