搜档网
当前位置:搜档网 › IP路由表分析

IP路由表分析

IP路由表分析
IP路由表分析

CCNA考点精析---IP路由表分析

当frame到达路由器的接口后,路由器检查frame中的目标地址字段,如果目标地址为路由器接口的地址或者广播地址的时候,路由器把packet从frame中剥离出来,传递给network layer,然后packet中的目标地址将被检查,接下来还要检查protocol字段,最后再发送给合适的进程,如果packet是可路由的,路由器会查找自己路由表中寻找相应

的路由条目,路由条目至少包含两个要素:

1、目标地址,这个地址是路由器必须能够到达的地址;

2、到达目标地址的指针,这个指针也就是我们平时在路由表中看到的Via.或者是平

时听说的next-hop(下一跳)

路由器根据packet中的目标地址字段,在路由表中执行查询,查询的精确程度按如下顺序

递减:

1、主机地址

2、子网地址

3、汇总网络号

4、主类网络号

5、超网号(super net)

6、默认路由

如果在执行完所有的表查询后,还没有找到匹配的条目,则丢弃packet,并回送一个(Destinnation Unreachable)ICMP不可达的报文给发送方在CISCO路由器上要查看路由表,可以使用特权命令:show ip route

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

配置静态路由的步骤

1、首先确定好每条链路的地址

2、为每台路由器找出非直连的链路

3、为每台路由器的非直连链路写出静态条目(直连没有必要写)

注:把未知交给已知

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

除已知条目外,其余全是它们各自的未知,此时我们可以用两种办法来配置静态路由

一、使用下一跳next-hop:

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

设置一条管理距离稍大于正常使用的一条静态路由,这样一来,当正常链路DOWN后,这条稍大的路由条目马上可以UP起来替代正常路由条目工作。

(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应该怎么走,所以该数据包被丢弃.

相关主题