2012-10-22 78 views

回答

0

我不知道純ARP通知,但你可以使用它運行在用戶空間,並適用於案件的地方文件arpd ARP表是非常大的。如果您使用arpd並對其進行修改,則可以使它向您發送有關arp表更改的通知。

1

如果我理解你的話 - 我建議你分析一下「ip」程序的來源。當您運行「ip monitor」並添加或刪除任何ARP條目時,「ip monitor」會顯示相應的消息。

1

一個應該使用NETLINK_ROUTE套接字和bind()到組RTNLGRP_NEIGH

之後,可以通過recv()得到ndmsg通知。請注意,必須使用所有通知,否則在溢出之後,套接字將引發ENOBUF異常,並將接下來的recv()

或者與外部ip(8)工具:

$ ip monitor all # get all the notifications 
$ ip monitor neigh # get only arp notifications 

或用一個Python library

from pyroute2 import IPRoute 
from pprint import pprint 

ip = IPRoute() 
ip.bind() # subscribe to all the events 
while True: 
    pprint(ip.get()) 
相關問題