将 ARP 表复制到数组
我一直在试图找出将 Linux ARP 表复制到数组中的最佳方法,我只需要 IP 和 MAC 地址。我尝试过复制 /proc/net/arp 文件,但我没有找到最好的方法,我读到除了 ARP(IPv6 或其他)之外可能还会出现其他条目。我不知道!还有其他方法可以获取本地 ARP 表吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
iproute2 中的
ip neighbor list
命令使用 < a href="http://swoolley.org/man.cgi/7/netlink" rel="nofollow">netlink 套接字来查询内核有关邻居信息。建议使用同一 iproute2 包中的 libnetlink 来访问此信息。
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.