Pydig python dns
Jump to navigation
Jump to search
Pydig
pip install pydig
import ipaddress import pydig resolver = pydig.Resolver( executable='/usr/bin/dig', nameservers=[ '1.1.1.1', '1.0.0.1', ], additional_args=[ '+time=10', ] ) ip="10.250.11.56" ptr=ipaddress.ip_address(ip).reverse_pointer rdns=pydig.query(ptr, 'PTR') rdns.sort() fqdns=[] for i in rdns: fqdn=i[:-1] fqdns.append(fqdn) print(fqdns)