Search code examples
arp

arp -a does not list all devices


I have an app which checks whether a certain IP is on the local network. The IP belongs to a raspberry pi working as a homeautomation device. Running the command

arp -a

from terminal or from within my app I get a list of all devices on the local network, but my raspberry pi is not always listed. After pinging the device, it appears on the list every time. Any ideas what is going wrong?


Solution

  • That's the way ARP works. ARP entries are created only when they're needed. The first time you need to communicate with an IP on the local network, your device broadcasts an ARP query, then caches the response. There's nothing that proactively fills in the cache for all IPs on the LAN.

    In addition, old entries may be removed from the cache if they haven't been used in a while.