Search code examples
clinuxnetwork-programmingarp

Copy ARP table to an array


I've been trying to figure out the best way to copy Linux ARP table into an array, I just need IP and MAC address. I have tried copying the /proc/net/arp file, but I do not find it the best way to do it, I read there might appear other entries beside ARP (IPv6 or sth). I am not sure! Is there any other option to get local ARP table?


Solution

  • The ip neighbor list command from iproute2 uses a netlink socket to query the kernel about the neighbour information.

    It is recommended to use the libnetlink from the same iproute2 package to access this information.