当 ARP 请求来自不同的子网时会发生什么?

gsi*_*nha 8 ethernet ip arp icmp

在以下两种情况下,从 router1 向 router2 发送 ARP Request 包会发生什么?会生成 ARP 回复还是丢弃 ARP 请求数据包?

  1. [router1]Intf1(20.0.0.1/24) ======== (40.0.0.1/24)Intf2[router2]
  2. [router1]Intf1(20.0.0.1/24) ======== (20.0.0.2/8) Intf2[router2]

上面的拓扑在路由器“router1”上的端口“Intf1”通过直接链路(例如,1 Gbps 电缆)连接到另一个路由器“router2”上的端口“Intf2”。

Mas*_*imo 28

ARP 仅适用于同一 IP 子网中的设备之间。

当具有 IP 地址 A 的设备 A 需要向具有 IP 地址 B 的设备 B 发送数据包时,它所做的第一件事就是查询其路由表以确定 IP 地址 B 是否属于它可以通过其网络接口直接到达的子网); 如果是,则设备 A 使用 ARP 将 IP 地址 B 映射到物理以太网地址,然后向该地址发送以太网帧。

但是如果两个 IP 地址在不同的子网上,设备将遵循完全不同的逻辑:它将在其路由表中查找到目标网络的路由,然后将其数据包发送到适当的路由器(或如果不存在更具体的路由,则默认网关);在这种情况下,会使用 ARP 来查找路由器的硬件地址,因为目的 IP 地址已经被认为是不可直接到达的,因此必须将数据包传递给可以处理它的路由器。


fuk*_*wi2 5

在某些情况下(我知道 Linux可以这样做,其他人不确定),但是主机可以响应“错误”接口上的 ARP。以这个网络为例:

10.0.0.0/24  ==== Host A ==== 192.168.0.0/24
Run Code Online (Sandbox Code Playgroud)

主机 A 在两个网络上都有一个地址;让我们说10.0.0.1192.168.0.1

如果主机 A 通过 10.0.0.1 接口收到 192.168.0.1 的 ARP,它将以 10.0.0.1 接口的 MAC 地址响应。

此行为由arp_ignore内核可调参数控制(来源:http : //blog.steve-miller.org/2010/03/tweaking-arp-behavior-in-linux.html):

arp_ignore - Define different modes for sending replies in response to received ARP requests that resolve local target IP addresses:
0 - (default): reply for any local target IP address, configured on any interface.
1 - reply only if the target IP address is local address configured on the incoming interface.
2 - reply only if the target IP address is local address configured on the incoming interface and both with the sender's IP address are part from same subnet on this interface.
3 - do not reply for local addresses configured with scope host, only resolutions for global and link addresses are replied.
4-7 - reserved
8 - do not reply for all local addresses.
Run Code Online (Sandbox Code Playgroud)

如上所述,默认是响应任何本地地址(即在主机 A 上配置的地址),而不管在哪个接口上接收 ARP。