- 积分
- 191
- 鸿鹄币
- 个
- 好评度
- 点
- 精华
- 最后登录
- 1970-1-1
- 阅读权限
- 20
- 听众
- 收听
助理工程师
 
|
递归路由、代理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个,总有些失败,请问这正常吗?造成这个的原因是什么?对实际应用会产生什么影响?
呵呵,我自己也有点模糊的理解,但是看不透彻,求交流指点!
|
|