import os
import re
file_name=input('the arp file name is:')
for i in open(file_name,'r').readlines():
host=re.findall('(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})',i)
# print(host)
if not host:
continue
else:
ip=host.pop()
command = 'nslookup %s'%ip
for k in os.popen(command).read().split('\n'):
domain = re.findall('name\s=\s(.*\w)\.',k)
if domain:
dns_record=domain.pop()
print(ip+ ' ' + dns_record)
if re.findall('.*server\scan\'t\sfind.*',k):
print(ip + ' no DNS record')
check the DNS record for the ARP entries
查询路由器交换机上ARP对应的DNS记录