【问题标题】:Sending gratuitous ARP messages发送免费 ARP 消息
【发布时间】:2013-06-10 17:00:46
【问题描述】:

我正在寻找一种在 Linux 用户空间应用程序中以编程方式(用 C 语言)发送免费 ARP 消息的方法。我注意到在

的 procfs 中有一些用于配置 ARP 的文件
/proc/sys/net/ipv4/conf/<interface_name> 

有没有办法通过对相应网络接口的 ioctl 调用来做到这一点?

【问题讨论】:

标签: c linux networking


【解决方案1】:

使用scapy:

from scapy.all import *

SELF_MAC = '02:02:02:02:02:02'    # fill in with your MAC address
BCAST_MAC = 'ff:ff:ff:ff:ff:ff'

def create_ARP_request_gratuituous(ipaddr_to_broadcast):
    arp = ARP(psrc=ipaddr_to_broadcast,
              hwsrc=SELF_MAC,
              pdst=ipaddr_to_broadcast)
    return Ether(dst=BCAST_MAC) / arp

# and then call sendp() with the result

【讨论】:

  • python 解决方案很好,但我正在寻找“C”解决方案。
  • 为什么是引号? C 是一种语言。
猜你喜欢
  • 2014-03-30
  • 1970-01-01
  • 2014-02-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-16
  • 2015-09-27
  • 2020-12-09
相关资源
最近更新 更多