设为首页收藏本站language 语言切换
查看: 3470|回复: 8
收起左侧

[已解决] 做静态路由的递归路由时产生的疑问,求指点

[复制链接]
发表于 2013-3-1 09:35:18 | 显示全部楼层 |阅读模式
递归路由、代理arp的实验
实验目的:当静态路由的下一跳为非直连ip时,研究递归路由的情况;研究arp的情况。
实验拓扑:

实验步骤:
1、配置完基本命令及ip
2、在R1上做静态路由,下一跳为R4的F0/0:ip route  4.4.4.0  255.255.255.0  f0/0  200.2.2.4
R2和R3:ip route 4.4.4.0 255.255.255.0 f0/1 200.2.2.4
3、R2,R2,R3都debug arp。
4、在R1:ping 4.4.4.4
观察结果:R1:
*Mar  1 01:07:56.203: IP ARP: creating incomplete entry for IP address: 200.2.2.4 interface FastEthernet0/0
*Mar  1 01:07:56.203: IP ARP: sent req src 100.1.1.1 c800.04c4.0000,
dst 200.2.2.4 0000.0000.0000 FastEthernet0/0
*Mar  1 01:07:56.255: IP ARP rep filtered src 200.2.2.4 c802.04c4.0000, dst 100.1.1.1 c800.04c4.0000 wrong cable, interface FastEthernet0/0
*Mar  1 01:07:56.255: IP ARP rep filtered src 200.2.2.4 c801.04c4.0000, dst 100.1.1.1 c800.04c4.0000 wrong cable, interface FastEthernet0/0.
*Mar  1 01:07:58.199: IP ARP throttled out the ARP Request for 200.2.2.4.
R2:
*Mar  1 01:07:26.531: IP ARP: rcvd req src 100.1.1.1 c800.04c4.0000, dst 200.2.2.4 FastEthernet0/0
*Mar  1 01:07:26.531: IP ARP: sent rep src 200.2.2.4 c801.04c4.0000,
dst 100.1.1.1 c800.04c4.0000 FastEthernet0/0
R3:
*Mar  1 01:06:55.627: IP ARP: rcvd req src 100.1.1.1 c800.04c4.0000, dst 200.2.2.4 FastEthernet0/0
*Mar  1 01:06:55.631: IP ARP: sent rep src 200.2.2.4 c802.04c4.0000,
dst 100.1.1.1 c800.04c4.0000 FastEthernet0/0
R1查找路由,知道到4.4.4.4的下一跳为200.2.2.4,但是不知道200.2.2.4怎么去,于是发送arp请求,通过f0/0端口广播出去,而R2、R3知道到200.2.2.4怎么去,同时代理arp是默认开启的,于是都回复arp reply,告诉R1 200.2.2.4的mac地址是自己的F0/0 mac地址。
于是R1收到的arp reply是这样的:200.2.2.4的mac地址是xxx-xxx-xxx(R2或者R3的相应端口mac)。同时R1又发现200.2.2.4不可达,于是丢弃。通过show arp验证是否丢弃:
r1#show arp
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  100.1.1.1               -   c800.04c4.0000  ARPA   FastEthernet0/0
Internet  100.1.1.2              71   c801.04c4.0000  ARPA   FastEthernet0/0
Internet  100.1.1.3              71   c802.04c4.0000  ARPA   FastEthernet0/0
r1#
可以发现,arp表中并没有200.2.2.4的项目。
5、从上面可以看到只要再给R1一个静态路由,告诉它200.2.2.4可达,是否就可以添加上200.2.2.4的arp项?好的,现在来做一下:
R1:
ip route 200.2.2.0 255.255.255.0 f0/0 100.1.1.2
ping 4.4.4.4
查看结果:
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
*Mar  1 01:30:32.247: IP ARP: creating incomplete entry for IP address: 200.2.2.4 interface FastEthernet0/0
*Mar  1 01:30:32.247: IP ARP: sent req src 100.1.1.1 c800.04c4.0000,
dst 200.2.2.4 0000.0000.0000 FastEthernet0/0
*Mar  1 01:30:32.299: IP ARP: rcvd rep src 200.2.2.4 c802.04c4.0000, dst 100.1.1.1 FastEthernet0/0
*Mar  1 01:30:32.303: IP ARP: rcvd rep src 200.2.2.4 c801.04c4.0000, dst 100.1.1.1 FastEthernet0/0…..
Success rate is 0 percent (0/5)
查看arp表show arp:
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  100.1.1.1               -   c800.04c4.0000  ARPA   FastEthernet0/0
Internet  100.1.1.2              83   c801.04c4.0000  ARPA   FastEthernet0/0
Internet  100.1.1.3              83   c802.04c4.0000  ARPA   FastEthernet0/0
Internet  200.2.2.4               3   c801.04c4.0000  ARPA   FastEthernet0/0
发现arp请求只发送了一次,并且在arp表里已经有了200.2.2.4的表项,上面显示为R2的f0/0 mac地址,如果在R4中有回包路由,就可以ping通了。所走的路径就是R1-R2-R4。
那么,在R1中,这条静态路由(称为A,  S    200.2.2.0/24 [1/0] via 100.1.1.2, FastEthernet0/0)的作用是什么?
A路由是为了主路由(称为B,  S       4.4.4.0 [1/0] via 200.2.2.4, FastEthernet0/0)而服务的,所以可以称A路由为递归路由,那么递归路由在寻径过程中的作用是什么?影不影响路径的选择?
仔细观察下递归路由S    200.2.2.0/24 [1/0] via 100.1.1.2, FastEthernet0/0,其中也有下一跳via 100.1.1.2,那么这个下一跳地址对于寻径有没有影响呢?是不是这样的:当这个下一跳为R2的F0/0时,就走上面的路径(R1-R2-R4);而当下一跳为R3的F0/0时,就走下面的路径(R1-R3-R4)?
下面我就来验证下能不能,先shutdown掉R2,然后重新写一个下一跳走R3的递归路由,看看结果。好的,我先让R1能够ping通:
6、在R4上做一个回包路由:ip route 100.1.1.0 255.255.255.0 f0/0 200.2.2.2
并且做个负载均衡
ip route 100.1.1.0 255.255.255.0 f0/0 200.2.2.3
查看结果R4:show ip route
100.0.0.0/24 is subnetted, 1 subnets
S       100.1.1.0 [1/0] via 200.2.2.2, FastEthernet0/0
[1/0] via 200.2.2.3, FastEthernet0/0
4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
C    200.2.2.0/24 is directly connected, FastEthernet0/0
R1:
r1#ping 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/50/96 ms
7、shutdown掉R2,重新做个走R3的递归路由
r2(config-if)#int f0
*Mar  1 02:17:39.147: %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to administratively down
*Mar  1 02:17:40.147: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to down
r2(config-if)#int f0/1
r2(config-if)#shutd
r2(config-if)#
*Mar  1 02:17:47.027: %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to administratively down
*Mar  1 02:17:48.027: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
R1:
r1(config)#no ip route 200.2.2.0 255.255.255.0 f0/0 100.1.1.2
r1(config)#ip route 200.2.2.0 255.255.255.0 f0/0 100.1.1.3
8、在R1、R4上打开debug,然后查看结果
r1#debug ip packet detail
IP packet debugging is on (detailed)
r1#debug ip icmp
ICMP packet debugging is on
r4#debug ip packet detail
IP packet debugging is on (detailed)
r4#debug ip icmp
ICMP packet debugging is on
查看结果R1:
r1#ping 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
*Mar  1 02:30:29.515: IP: s=100.1.1.1 (local), d=4.4.4.4 (FastEthernet0/0), len 100, sending
*Mar  1 02:30:29.515:     ICMP type=8, code=0.
*Mar  1 02:30:31.515: IP: s=100.1.1.1 (local), d=4.4.4.4 (FastEthernet0/0), len 100, sending
*Mar  1 02:30:31.515:     ICMP type=8, code=0.
*Mar  1 02:30:33.515: IP: s=100.1.1.1 (local), d=4.4.4.4 (FastEthernet0/0), len 100, sending
*Mar  1 02:30:33.515:     ICMP type=8, code=0.
*Mar  1 02:30:35.515: IP: s=100.1.1.1 (local), d=4.4.4.4 (FastEthernet0/0), len 100, sending
*Mar  1 02:30:35.515:     ICMP type=8, code=0.
*Mar  1 02:30:37.515: IP: s=100.1.1.1 (local), d=4.4.4.4 (FastEthernet0/0), len 100, sending
*Mar  1 02:30:37.515:     ICMP type=8, code=0.
Success rate is 0 percent (0/5)
而这个时候R4上没有收到任何数据包
r4#debug ip packet detail
IP packet debugging is on (detailed)
r4#debug ip icmp
ICMP packet debugging is on
r4#
r4#
这代表R2 DOWN掉的时候,仍然走的是上面的路径,并没有走下面的路径。
所以递归路由的作用仅仅是在R1收到ARP Reply时,告诉R1这个reply是可信赖的,即目标网段是可达的。无论下一跳地址是什么,都不影响路径的选择,而影响路径选择的是R1的arp表中目标地址的mac,这个mac地址是由R2、R3的 arp reply决定的,即R2、R3的arp reply谁后到,谁就是arp表项中的地址。
但是递归路由的作用是为了增加静态路由的灵活性
那么怎么样才能实现这个灵活性呢?即当R2 DOWN的时候走下面的路径,R3 DOWN的时候走下面的路径?
这个时候要先了解一下arp发送的根本原理:在路由器中,对于一个目的ip地址,如果arp中有这个IP的表项,那么除非这个表项消失,否者路由器永远不会对这个IP地址进行arp请求。而arp表项的存在时间默认是4个小时。
所以,只要修改了arp表项的存在时间,就可以很快速的实现路由切换。
好的,我来做一下:
9、修改R1的arp表项 存在时间为10秒,同时也要修改R4的为10秒
r1(config)#int f0/0
r1(config-if)#arp timeout ?
<0-2147483>  Seconds
r1(config-if)#arp timeout 10
这个时候,R1马上就产生了一个提示信息
*Mar  1 02:48:01.267: IP ARP: sent req src 100.1.1.1 c800.04c4.0000,
dst 100.1.1.2 c801.04c4.0000 FastEthernet0/0
*Mar  1 02:48:01.267: IP ARP: sent req src 100.1.1.1 c800.04c4.0000,
dst 100.1.1.3 c802.04c4.0000 FastEthernet0/0
*Mar  1 02:48:01.267: IP ARP: sent req src 100.1.1.1 c800.04c4.0000,
dst 200.2.2.4 c801.04c4.0000 FastEthernet0/0
*Mar  1 02:48:01.287: IP ARP: rcvd rep src 100.1.1.3 c802.04c4.0000, dst 100.1.1.1 FastEthernet0/0
*Mar  1 02:48:01.291: IP ARP: creating entry for IP address: 100.1.1.3, hw: c802.04c4.0000
这个就意味这arp表项的消失,查看一下arp表
r1#show arp
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  100.1.1.1               -   c800.04c4.0000  ARPA   FastEthernet0/0
Internet  100.1.1.3               0   c802.04c4.0000  ARPA   FastEthernet0/0
发现200.2.2.4的表项已经消失了。
10、查看结果
R1:
r1#ping 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
*Mar  1 03:00:15.871: IP: s=100.1.1.1 (local), d=4.4.4.4 (FastEthernet0/0), len 100, sending
*Mar  1 03:00:15.875:     ICMP type=8, code=0.!
*Mar  1 03:00:17.871: IP: s=100.1.1.1 (local), d=4.4.4.4 (FastEthernet0/0), len 100, sending
*Mar  1 03:00:17.871:     ICMP type=8, code=0
*Mar  1 03:00:17.887: IP: s=4.4.4.4 (FastEthernet0/0), d=100.1.1.1 (FastEthernet0/0), len 100, rcvd 3
*Mar  1 03:00:17.891:     ICMP type=0, code=0
*Mar  1 03:00:17.891: ICMP: echo reply rcvd, src 4.4.4.4, dst 100.1.1.1
*Mar  1 03:00:17.891: IP: s=100.1.1.1 (local), d=4.4.4.4 (FastEthernet0/0), len 100, sending
*Mar  1 03:00:17.891:     ICMP type=8, code=0.!
*Mar  1 03:00:19.891: IP: s=100.1.1.1 (local), d=4.4.4.4 (FastEthernet0/0), len 100, sending
*Mar  1 03:00:19.891:     ICMP type=8, code=0
*Mar  1 03:00:19.923: IP: s=4.4.4.4 (FastEthernet0/0), d=100.1.1.1 (FastEthernet0/0), len 100, rcvd 3
*Mar  1 03:00:19.923:     ICMP type=0, code=0
*Mar  1 03:00:19.923: ICMP: echo reply rcvd, src 4.4.4.4, dst 100.1.1.1
*Mar  1 03:00:19.923: IP: s=100.1.1.1 (local), d=4.4.4.4 (FastEthernet0/0), len 100, sending
*Mar  1 03:00:19.927:     ICMP type=8, code=0.
Success rate is 40 percent (2/5), round-trip min/avg/max = 20/26/32 ms
多ping几次
r1#ping 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!
*Mar  1 03:01:24.403: IP: s=100.1.1.1 (local), d=4.4.4.4 (FastEthernet0/0), len 100, sending
*Mar  1 03:01:24.403:     ICMP type=8, code=0
*Mar  1 03:01:24.471: IP: s=4.4.4.4 (FastEthernet0/0), d=100.1.1.1 (FastEthernet0/0), len 100, rcvd 3
*Mar  1 03:01:24.471:     ICMP type=0, code=0
*Mar  1 03:01:24.471: ICMP: echo reply rcvd, src 4.4.4.4, dst 100.1.1.1
*Mar  1 03:01:24.475: IP: s=100.1.1.1 (local), d=4.4.4.4 (FastEthernet0/0), len 100, sending
*Mar  1 03:01:24.475:     ICMP type=8, code=0.!
*Mar  1 03:01:26.471: IP: s=100.1.1.1 (local), d=4.4.4.4 (FastEthernet0/0), len 100, sending
*Mar  1 03:01:26.471:     ICMP type=8, code=0
*Mar  1 03:01:26.503: IP: s=4.4.4.4 (FastEthernet0/0), d=100.1.1.1 (FastEthernet0/0), len 100, rcvd 3
*Mar  1 03:01:26.503:     ICMP type=0, code=0
*Mar  1 03:01:26.503: ICMP: echo reply rcvd, src 4.4.4.4, dst 100.1.1.1
*Mar  1 03:01:26.507: IP: s=100.1.1.1 (local), d=4.4.4.4 (FastEthernet0/0), len 100, sending
*Mar  1 03:01:26.507:     ICMP type=8, code=0.!
Success rate is 60 percent (3/5), round-trip min/avg/max = 24/44/72 ms

上面是我自己做过实验后写的笔记的一部分,其中最后在R1上ping 4.4.4.4的时候,成功的包总是2个或者3个,总有些失败,请问这正常吗?造成这个的原因是什么?对实际应用会产生什么影响?
呵呵,我自己也有点模糊的理解,但是看不透彻,求交流指点!                                                               
发表于 2013-3-1 10:07:48 | 显示全部楼层
沙发 2013-3-1 10:07:48 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2013-3-1 11:03:30 | 显示全部楼层
应该不会丢包的呀
板凳 2013-3-1 11:03:30 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2013-3-1 11:14:42 | 显示全部楼层
为什么你R1写静态路由的下一跳写到R4的入接口??你又不是mpls,打双层label。难道有我不知道的地方??在以太网下,你R1写静态写出接口就可以了啦,不然就指定R2或者R3为你的下一跳,他们接口默认开启的代理ARP可以为switch找到DIP4.4.4.4的mac,到了R2或者R3进行路由表的递归查找,就知道下一跳是谁了,发给switch2后,switch2也会进行switch1同样的操作啊。
至于你后面问为什么会有几个通几个不通,你先试试我这个方法后,那个问题还会出现不,在进一步给你回答咯~
地板 2013-3-1 11:14:42 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2013-3-1 15:08:33 | 显示全部楼层
5# 2013-3-1 15:08:33 回复 收起回复
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-3-1 18:00:37 | 显示全部楼层
璃箜-博 发表于 2013-3-1 11:14
为什么你R1写静态路由的下一跳写到R4的入接口??你又不是mpls,打双层label。难道有我不知道的地方??在以 ...

这个实验的目的就是研究静态路由下一跳不是直连ip时的包发送情况。通过这个路由和递归路由来尝试增加静态路由的灵活性。不过还是谢谢你的热心帮忙了,我自己大概懂了原因:
因为arp表项存在时间为10,造成了arp表的抖动和不稳定,R1或者R4中很有可能arp表项已死亡,所以在重新请求,这需要一点时间,所以很容易造成通几个丢几个的情况了。
6# 2013-3-1 18:00:37 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2013-3-1 19:59:41 | 显示全部楼层
shelnard 发表于 2013-3-1 18:00
这个实验的目的就是研究静态路由下一跳不是直连ip时的包发送情况。通过这个路由和递归路由来尝试增加静态 ...

哦哦,原来是这样,但是我不是很认同,arp表的老化时间不止10s吧?而且在你ping的任何时候,只要是通讯过程中,arp表就一直老化时间归0啦,根本没有重新发arp请求的可能啊?
你有解决么,有的话,不吝赐教~
7# 2013-3-1 19:59:41 回复 收起回复
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-3-2 10:13:02 | 显示全部楼层
璃箜-博 发表于 2013-3-1 19:59
哦哦,原来是这样,但是我不是很认同,arp表的老化时间不止10s吧?而且在你ping的任何时候,只要是通讯过 ...

为什么没有重新发arp请求?只要我arp表里没有这项,而我又请求和这个ip通讯,当然要先发送arp请求喽。
至于arp表老化时间,默认的是4小时,我实验中改为了10秒。亲,你并没有看我的实验步骤啊,
8# 2013-3-2 10:13:02 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2016-2-20 08:58:20 | 显示全部楼层
虽然这个时间隔很久。图也裂了。但是我没看懂为什么下一跳要指R4的F0/0,这样的静态在本地会有效么?如果R1本地接口是F0/1。
9# 2016-2-20 08:58:20 回复 收起回复
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 论坛注册

本版积分规则

QQ|Archiver|手机版|小黑屋|sitemap|鸿鹄论坛 ( 京ICP备14027439号 )  

GMT+8, 2025-5-21 15:48 , Processed in 0.075164 second(s), 26 queries , Redis On.  

  Powered by Discuz!

  © 2001-2025 HH010.COM

快速回复 返回顶部 返回列表