Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using libnet to send ARP request, but arp cache won't update after getting the ARP reply

I need to look up MAC address in the local network and I'm using Linux. What I do is send a ARP request with libnet, but after I send 3 requests, the cache still won't update. I use wireshark to catch the packets. From wireshark, I did get 3 ARP replays, after each of my ARP request. Does anyone know how come the ARP cache won't update?

like image 823
Aitjcize Avatar asked Jul 29 '10 05:07

Aitjcize


People also ask

Why is ARP not resolved?

When the ARPs are not resolved, most likely the ARPS for the SGW user IP and the Network Host next hop are not configured correctly. And there are two things could cause the ARP issue. One, the GlueServer is not ready or running. Two, the interfaces on the DUT are not up.

What ARP does when it does not receive a response to the ARP request?

What will happen if an ARP reply is not received for an ARP request? If an ARP reply is not received, then that IP address cannot be resolved to an Ethernet address. Without a Ethernet address, the packets cannot be transmitted.

Does switch reply to ARP?

If the device with the IP address is directly attached to the Layer 3 switch, the device sends an ARP response containing its MAC address. The response is a unicast packet addressed directly to the Layer 3 switch. The Layer 3 switch places the information from the ARP response into the ARP cache.

What the switch will do when receiving ARP request packet?

When the ARP reply is received, the switch then knows the destination MAC address, so it fills the ARP table; additionally, the switch can fill the CAM table because it already knows the physical port and VLAN the ARP reply came from. So now the Ethernet frame is complete and it can be forwarded.


1 Answers

The Linux kernel does not accept unsolicited ARP by default. Since the request was sent by your userspace application and not by the kernel, the kernel sees the reply as "unsolicited".

You can change this default in /proc/sys/net/ipv4/conf/*/arp_accept (either on a per-device basis or across all devices).

like image 140
caf Avatar answered Nov 04 '22 02:11

caf