def __init__(self, interface, pool, gateway, dns): self.server_mac = GET_MAC(interface) self.server_ip = get_ip_address(interface) self.subnet_mask = '255.255.255.0' self.pool = pool self.gateway = gateway self.dns = dns
def get_arp(ip_address, ifname): #localip = get_ip_address(ifname) #获取本机IP地址 localip = get_ip_address(ifname) #获取本机MAC地址 localmac = get_mac_address(ifname) #发送ARP请求并等待响应 result_raw = srp(Ether(src=localmac, dst='FF:FF:FF:FF:FF:FF')/ARP(op=1, hwsrc=localmac, hwdst='00:00:00:00:00:00', psrc=localip, pdst=ip_address), iface = ifname, verbose = False) #把响应的数据包对,产生为清单 result_list = result_raw[0].res #[0]第一组响应数据包 #[1]接受到的包,[0]为发送的数据包 #[1]ARP头部字段中的['hwsrc']字段,作为返回值返回 return result_list[0][1][1].fields['hwsrc']
def get_arp(ip_address, ifname): #localip = get_ip_address(ifname) #获取本机IP地址 localip = get_ip_address(ifname) #获取本机MAC地址 localmac = get_mac_address(ifname) #发送ARP请求并等待响应 result_raw = srp(Ether(src=localmac, dst='FF:FF:FF:FF:FF:FF') / ARP(op=1, hwsrc=localmac, hwdst='00:00:00:00:00:00', psrc=localip, pdst=ip_address), iface=ifname, verbose=False) #把响应的数据包对,产生为清单 result_list = result_raw[0].res #[0]第一组响应数据包 #[1]接受到的包,[0]为发送的数据包 #[1]ARP头部字段中的['hwsrc']字段,作为返回值返回 return result_list[0][1][1].fields['hwsrc']