blob: 65ae68bad0a64e7850ce3111b18671182d4e2a15 [file] [log] [blame]
DR695H5fa01462017-02-15 18:21:12 -05001import dns.message
2import dns.name
3import dns.query
4
5class DNSUtils:
6 """ Utilities useful for DNS requests """
7
8 def dns_request(self, domain, ns):
9 """ return the ip address of the given domain name from the given nameserver """
10 request = dns.message.make_query(domain, dns.rdatatype.A);
11 request.flags |= dns.flags.AD;
12 request.find_rrset(request.additional, dns.name.root, 65535, dns.rdatatype.OPT, create=True, force_unique=True)
13 response = dns.query.udp(request, ns)
14
15 for answer in response.answer:
16 for item in answer.items:
17 return item