路由和ARP

如果我有

>ip ro 192.168.14.0/24 dev eth0 

另一台主机可以获得我的mac地址。 但是,如果我刷新路由信息:

 >ip ro flush table main 

ARP分辨率不起作用。 广播数据包“谁有192.168.14.149”到达eth0,但尽pipeeth0的地址为192.168.14.149,但OS(Linux)仍然不响应。 路由和arpparsing之间有什么连接?

在Linux上,当接口出现时,本地networking会自动创build路由。

因此,如果您已将IP地址192.168.14.12分配给eth0,则应创build如下所示的路由。

 192.168.14.0/24 dev eth0 proto kernel scope link src 192.168.14.12 

如果该链接路由不存在,您将无法发送或接收数据包。

通过运行命令ip ro flush table main您将删除所有路由,包括系统上主路由表中的链路路由。 从那个Linux的盒子里,你可以通过简单地Ping另一个IP地址来testing事情是否被严重破坏。 你会得到一个Network is unreachable错误。 没有路由表在所有的Linux不会或真的在networking上做任何事情。

您可以使用像这样的命令删除分配的路由而不删除链接路由。

 ip ro flush table main scope global 

当你试图做一些高级的事情,例如使用代理ARP来创build虚拟桥,这种操纵链路路由的能力确实派上用场。

描述的行为与启用的/proc/sys/net/ipv4/*/arp_ignore 。 在某些情况下, arp_filterrp_filter可能导致类似的行为。

 arp_ignore - INTEGER 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 The max value from conf/{all,interface}/arp_ignore is used when ARP request is received on the {interface}