代理ARP产生路由环路问题分析

ARP的工作机制:

  • 当一台设备需要发现另一台设备的MAC地址时,它将发送一个ARP Request数据包。这个Request数据包中包括:发送者的IP地址、发送者的MAC地址,目标的IP地址、目标全0的MAC地址(00:00:00:00:00:00),并以广播(ff.ff.ff.ff.ff.ff)的方式发送出去。
  • 广播地址意味着数据链路上的所有设备都将收到该帧,并且要检查数据帧内封装的数据包。除了目标机可以识别该数据包外,其他设备都会丢弃该数据包。目标机将向源地址发送ARP Reply数据包,并提供它的MAC地址。

R1#ping 172.16.1.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 172.16.1.2, timeout is 2 seconds:

.!!!!

Success rate is 80 percent (4/5), round-trip min/avg/max = 48/55/72 ms

R2#debug arp

R2#

*Mar  1 01:35:21.835: IP ARP: rcvd req src 172.16.1.1 c201.22a8.0001, dst 172.16.1.2 FastEthernet0/0

*Mar  1 01:35:21.839: IP ARP: creating entry for IP address: 172.16.1.1, hw: c201.22a8.0001

*Mar  1 01:35:21.839: IP ARP: sent rep src 172.16.1.2 c202.2964.0000,

                 dst 172.16.1.1 c201.22a8.0001 FastEthernet0/0

//R2收到了R1的ARP请求,并进行了应答

R3#debug arp

R3#

*Mar  1 01:35:21.895: IP ARP: rcvd req src 172.16.1.1 c201.22a8.0001, dst 172.16.1.2 FastEthernet0/0

//R3收到了R1的ARP请求,因不是请求自己的,所以不作应答

R2收到R1的ARP请求

R1的ARP请求数据包

R2给R1做的ARP应答数据包

R3收到了R1发送的ARP广播请求

R3收到的R1 ARP请求数据包

查看ARP表项

R1#show arp

Protocol  Address          Age (min)    Hardware Addr         Type      Interface

Internet  172.16.1.1              -            c201.22a8.0001        ARPA     FastEthernet0/1

Internet  172.16.1.2             29           c202.2964.0000        ARPA    FastEthernet0/1

//Age一栏表明了ARP表项已保存的时间,Cisco路由器默认保存ARP表项的时间为4个小时,该值可修改

修改ARP表项超时时间

R1(config)#int f0/1

R1(config-if)#arp timeout 120

Cisco路由器静态绑定ARP表项

R1(config)#arp 172.16.1.3 c203.0d50.0000 arpa

R1(config)#do show arp

Protocol  Address          Age (min)      Hardware Addr     Type     Interface

Internet  172.16.1.1              -              c201.22a8.0001     ARPA    FastEthernet0/1

Internet  172.16.1.2              0              c202.2964.0000     ARPA    FastEthernet0/1

Internet  172.16.1.3              -               c203.0d50.0000     ARPA 

代理ARP工作机制:

  • 代理ARP被路由器作为向主机表明自身可用的一种手段(路由器欺骗了本地主机)。
  • 当一台路由器收到了一个ARP Request数据包,并且该路由器知道如何到达目的网络,则路由器将回复一个ARP Reply,并将自己的MAC地址填充ARP Reply数据包中的被请求目标MAC地址。

R3模拟一台主机,关闭路由功能,R3(config)#no ip routing

R2仅配置接口IP地址,不做任何其他配置

R1配置一条到100.1.1.3/32的主机路由下一跳指向R2 f0/0,R1(config)#ip route 100.1.1.3 255.255.255.255 12.1.1.2

R1#show ip route

Gateway of last resort is not set

      12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C        12.1.1.0/24 is directly connected, FastEthernet0/1

L        12.1.1.1/32 is directly connected, FastEthernet0/1

      100.0.0.0/8 is variably subnetted, 3 subnets, 2 masks

C        100.1.1.0/24 is directly connected, FastEthernet0/0

L        100.1.1.1/32 is directly connected, FastEthernet0/0

S        100.1.1.3/32 [1/0] via 12.1.1.2

思科路由器接口默认已开启代理ARP

初始状态下R2的ARP缓存只有自己本地接口ARP表项

R2#show arp

Protocol  Address          Age (min)  Hardware Addr   Type   Interface

Internet  12.1.1.2                -   ca02.08b4.0008          ARPA   FastEthernet0/0

Internet  100.1.1.2              -   ca02.08b4.0006          ARPA   FastEthernet0/1

R2#

在R1、R2、R3上都开启 #debug arp

在R1上跟踪100.1.1.3,查看输出结果,发现R1和R2之间出现了路由环路,

R1#traceroute 100.1.1.3

Type escape sequence to abort.

Tracing the route to 100.1.1.3

VRF info: (vrf in name/id, vrf out name/id)

  1

*Jun 24 14:05:00.875: IP ARP: rcvd req src 12.1.1.2 ca02.08b4.0008, dst 12.1.1.1 FastEthernet0/1

*Jun 24 14:05:00.875: IP ARP: sent rep src 12.1.1.1 ca01.20fc.0006,

                 dst 12.1.1.2 ca02.08b4.0008 FastEthernet0/1 *

    12.1.1.2 36 msec 44 msec

  2 100.1.1.1 60 msec 24 msec 32 msec

  3 12.1.1.2 60 msec 56 msec 60 msec

  4 100.1.1.1 60 msec 64 msec 64 msec

  5 12.1.1.2 84 msec 88 msec 92 msec

  6 100.1.1.1 100 msec 88 msec 92 msec

  7 12.1.1.2 112 msec

*Jun 24 14:05:03.967: IP ARP: rcvd req src 100.1.1.2 ca02.08b4.0006, dst 100.1.1.3 FastEthernet0/0

*Jun 24 14:05:03.971: IP ARP: sent rep src 100.1.1.3 ca01.20fc.0008,

                 dst 100.1.1.2 ca02.08b4.0006 FastEthernet0/0 124 msec 120 msec

//由于思科路由器默认开启代理ARP,R1有到达100.1.1.3的路由,所以在100.1.1.0/24的MA网段,为R2回复了一个ARP Reply报文,告诉R2到达100.1.1.3的MAC地址,也就是自己f0/0接口的MAC地址ca01.20fc.0008

  8 100.1.1.1 128 msec 112 msec 128 msec

  9 12.1.1.2 148 msec 152 msec 152 msec

 10 100.1.1.1 156 msec 152 msec 152 msec

 11 12.1.1.2 184 msec 180 msec 184 msec

 12 100.1.1.1 188 msec 184 msec 184 msec

…… 省略

R1#

R2上查看ARP缓存

R2#show arp

Protocol  Address             Age (min)  Hardware Addr       Type   Interface

Internet  12.1.1.1                    9      ca01.20fc.0006           ARPA   FastEthernet0/0

Internet  12.1.1.2                    -      ca02.08b4.0008          ARPA   FastEthernet0/0

Internet  100.1.1.2                  -      ca02.08b4.0006          ARPA   FastEthernet0/1

Internet  100.1.1.3               9      ca01.20fc.0008          ARPA   FastEthernet0/1

R2#

为什么R2只收到了R1的ARP Reply,而没有收到R3的Replay呢?通过debug返回信息可以看到,R3也给R2回复了Reply,只是R3先回复的,R1后回复的,后回复的覆盖了先回复的ARP表项

R2#

*Jun 24 14:05:00.855: IP ARP: creating incomplete entry for IP address: 12.1.1.1 interface FastEthernet0/0

*Jun 24 14:05:00.859: IP ARP: sent req src 12.1.1.2 ca02.08b4.0008,

                 dst 12.1.1.1 0000.0000.0000 FastEthernet0/0

*Jun 24 14:05:00.887: IP ARP: rcvd rep src 12.1.1.1 ca01.20fc.0006, dst 12.1.1.2 FastEthernet0/0

R2#

*Jun 24 14:05:03.951: IP ARP: creating incomplete entry for IP address: 100.1.1.3 interface FastEthernet0/1

*Jun 24 14:05:03.955: IP ARP: sent req src 100.1.1.2 ca02.08b4.0006,

                 dst 100.1.1.3 0000.0000.0000 FastEthernet0/1

*Jun 24 14:05:03.983: IP ARP: rcvd rep src 100.1.1.3 ca03.211c.0008, dst 100.1.1.2 FastEthernet0/1

*Jun 24 14:05:03.987: IP ARP: rcvd rep src 100.1.1.3 ca01.20fc.0008, dst 100.1.1.2 FastEthernet0/1

//最后两行可以看到R3、R1向R2回复的ARP Reply报文,只是R1后回复的,覆盖了R3回复的表项

R2的f0/1接口抓包分析也可以看到ARP Reply回复的报文

解决该问题的办法有两种。一种是关闭R1 f0/0接口的代理ARP功能:

R1(config)#int f0/0

R1(config-if)#no ip proxy-arp

第二种是在R2上为100.1.1.3配置静态ARP表项:

R2(config)#arp 100.1.1.3 ca03.211c.0008 arpa

R2#

*Jun 24 14:26:25.511: %SYS-5-CONFIG_I: Configured from console by console

R2#show arp

Protocol  Address          Age (min)  Hardware Addr   Type   Interface

Internet  12.1.1.1               21   ca01.20fc.0006  ARPA   FastEthernet0/0

Internet  12.1.1.2                -   ca02.08b4.0008  ARPA   FastEthernet0/0

Internet  100.1.1.2               -   ca02.08b4.0006  ARPA   FastEthernet0/1

Internet  100.1.1.3               -   ca03.211c.0008  ARPA 

R2#

以上解决办法完成之后,到R1上再次验证

R1#traceroute 100.1.1.3

Type escape sequence to abort.

Tracing the route to 100.1.1.3

VRF info: (vrf in name/id, vrf out name/id)

  1 12.1.1.2 20 msec 28 msec 24 msec

  2 100.1.1.3 60 msec 60 msec 36 msec

R1#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值