[英]Receiving multicast Ethernet frames
如何在 Python 中偵聽尋址到多播 MAC 地址(例如77:77:77:77:77:77
)的原始以太網幀?
我正在聽這樣的原始幀:
s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(ETH_TYPE))
s.bind(("eth0", 0))
s.recv(2048)
我可以使用tcpdump
看到到達eth0
的幀,但上面的代碼沒有看到它們。 我想我需要告訴 kernel 我對它們發送到的多播 MAC 地址感興趣,但不知道如何發送。
Ethertype 字段設置為非標准值,並且幀內容不是已發布的協議。
我對 LLDP(多播)有同樣的問題,結果證明
ip link set eth0 allmulticast on
或者
ip link set eth0 promisc on
兩者都對我有用。
編輯:找到另一種安全的方式:
ip maddress add 01:80:c2:00:00:0e dev eth0
對於我的情況(LLDP)。 其中01:80:c2:00:00:0e
是LLDP報文的目的mac。
見https://github.com/jjqq2013/simple-lldp-capture-python-script/blob/main/lldp.sh
對於您的情況,它應該是:
ip maddress add 77:77:77:77:77:77 dev eth0
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.