扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
R1#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.123.0/24 is directly connected, FastEthernet0/0
1.0.0.0/24 is subnetted, 3 subnets
C 1.1.1.0 is directly connected, Loopback0
C 1.1.2.0 is directly connected, Loopback1
C 1.1.3.0 is directly connected, Loopback2
C 192.168.14.0/24 is directly connected, Serial1/2 |
如果你只想检查静态的路由条目,则可以在show ip route命令后加上static参数,依此类推……
Configuration static routes
R1(config)#ip route 2.2.1.2 255.255.255.0 192.168.12.2 R1(config)#ip route 2.2.2.2 255.255.255.0 192.168.12.2 R1(config)#ip route 2.2.3.2 255.255.255.0 192.168.12.2 |
谁是自己的未知?——所有非直连的链路
谁是自己的已知?——直连链路
在直连链路上有两种选择:下一跳(next-hop)和出接口(interface)
分别看一下两者的区别
下一跳是和自己直连路由器的接口地址,而出接口则是自己本身的接口名称
就好象一条隧道的入口和出口:出口就是下一跳,入口是出接口
R1和R2通过FA0/0——FA0/0,S1/1——S1/0
FA0/0口的IP分别为192.168.123.1/192.168.123.2
S1/1的IP为:192.168.12.1
S1/0的IP为:192.168.12.2
它们各自有三条直连网段:
1.1.1.1 1.1.2.1 1.1.3.1和 2.2.1.2 2.2.2.2 2.2.3.2 |
分析:
对于R1来说,它的已知是:
192.168.123.0/24 192.168.12.0/24 1.1.1.0/24 1.1.2.0/24 1.1.3.0/24 |
对于R2来说,它的已知是:
192.168.123.0/24 192.168.12.0/24 2.2.1.0/24 2.2.2.0/24 2.2.3.0/24 |
R2(config)#ip route 1.1.1.0 255.255.255.0 192.168.123.1 R2(config)#ip route 1.1.2.0 255.255.255.0 192.168.123.1 R2(config)#ip route 1.1.3.0 255.255.255.0 192.168.123.1 |
红字标识的即为next-hop
看一下路由表:
R2#sh ip route static 1.0.0.0/24 is subnetted, 3 subnets S 1.1.1.0 [1/0] via 192.168.123.1 S 1.1.2.0 [1/0] via 192.168.123.1 S 1.1.3.0 [1/0] via 192.168.123.1 |
到达三个未知的地方全部都交给了 via 192.168.123.1 ,注意[]里的数字[1/0]
二、使用出接口interface:
R1(config)#ip route 2.2.1.0 255.255.255.0 serial 1/1 R1(config)#ip route 2.2.2.0 255.255.255.0 serial 1/1 R1(config)#ip route 2.2.3.0 255.255.255.0 serial 1/1 |
红字标识的地方即为出接口
看一下路由表:
R1#sh ip route static 2.0.0.0/24 is subnetted, 3 subnets S 2.2.1.0 is directly connected, Serial1/1 S 2.2.2.0 is directly connected, Serial1/1 S 2.2.3.0 is directly connected, Serial1/1 |
这里已经没有[]了。取而代之的是directly connected,说明路由器R1认为这些条目都是自己直连的条目。
路由器在路由选择的过程中会比较哪条路是更好的路
这时候如果用第一种方法给它配上相同的路由条目,看一下会出现什么情况:
R1(config)#ip route 2.2.1.0 255.255.255.0 192.168.12.2 R1(config)#ip route 2.2.2.0 255.255.255.0 192.168.12.2 R1(config)#ip route 2.2.3.0 255.255.255.0 192.168.12.2 R1#sh ip route sta R1#sh ip route static 2.0.0.0/24 is subnetted, 3 subnets S 2.2.1.0 is directly connected, Serial1/1 [1/0] via 192.168.12.2 S 2.2.2.0 is directly connected, Serial1/1 [1/0] via 192.168.12.2 S 2.2.3.0 is directly connected, Serial1/1 [1/0] via 192.168.12.2 |
R1认为现在R1到达R2后面的直连网络可以有两条路走了,其实只有这一条通道,却被R1认为是两条不同的路。可见,这两种方法需要根据情况使用,否则可能会出现路由选择的问题。
Floating Static Routes
(1)Router(config)#ip route 1.1.1.0 255.255.255.0 192.168.123.2 (2)Router(config)#ip route 1.1.1.0 255.255.255.0 192.168.12.2 50 |
如上,当(1)down后,(2)会自动地up,顶替(1)
以下为例题:
1、Users on the 172.17.22.0 network cannot reach the server located on the 172.31.5.0 network. The network administrator connected to router Coffee via the console port, issued the show ip route command, and was able to ping the server. Based on the output of the show ip route command and the topology shown in the graphic, what is the cause of the failure?

A: The network has not fully converged.
B: IP routing is not enabled.
C: A static route is configured incorrectly.
D: The FastEthernet interface on Coffee is disabled.
E: The neighbor relationship table is not correctly updated.
F: The routing table on Coffee has not updated .
Correct Answers: C
该题中,172.18.22.0网段的用户无法访问到172.31.5.0的服器,管理员通过show ip route命令看到了如下的路由表记录,试分析哪些说法是正确的。
首先比较以下两条直连路由条目,正常;下面的一条静态默认路由的下一跳地址却有问题,因为网络中并没有172.19.22.2这个地址。假设现在从 172.17.22.0有主机A向172.31.5.0中的SERVER发送信息,数据报文进入Coffee后,Coffee经过查表得知,该路由条目并未存在于路由表中,所以被匹配默认路由,交给下一跳172.19.22.2,但是Coffee却发现并不知道 172.19.22.2应该怎么走,所以该数据包被丢弃。
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
去集群 更超群——大容量网络演进之路
2019 IBM 中国论坛
H3C 2019 Navigate 领航者峰会
助推数据中心网络现代化转型 打造灵活可靠基础架构平台