需求: 机房 DELL 服务器, 网卡配置 DHCP, 需要拿到他们的 IP 地址
import scapy
def mac_to_ip(mac, net_scope):
# mac 为 mac 地址
# net_scope 为 网段
pkg = Ether(dst=mac)/ARP(pdst=net_scopte)
ans, unans = srp(pkg, verbose=False, timeout=1)
for k, v in ans:
if v.sprintf("%Ether.src%").lower() == mac.lower():
return v.sprintf("%ARP.psrc%")