I was hoping you could point me in the right direction about a little problem I'm having.
I want to create a basic web app that performs DNS queries to validate whether a specific set of DNS records are active or not. The DNS records are all A records and are hosted on an SQL-based CMDB.
I'm a fan of python and would prefer to use it but I have no idea where to start. The use case I'm looking at is as follows:
- Browse to http://hostname/pythonDnsTool.html
- Click [RUN QUERY] button
- Script queries the [DnsARecord] table to validate whether a list of dnsNames exist or not
- Upon completion http://hostname/pythonDnsTool.html returns a list of queried domains with a YES or NO
Any advice or guidance would be greatly appreciated.
Many thanks,
Westie5017
There are a few tools, which one is the best depends on your needs.
1] A great python tool that does what you ask and a lot more is scapy . For example:
>>> packet = DNSQR()
>>> packet.show()
###[ DNS Question Record ]###
qname= '.'
qtype= A
qclass= IN
As you can see it gives you the ability to craft your packets in high level. For example if you wanted to send a simple DNS query and get an answer back you could do something like that:
sr1(IP(dst="some_ip")/UDP()/DNS(rd=1,qd=DNSQR(qname="")))
But again this is only a minimal example of the things you can do. For more information take a look at: here and here (scapy's general documentation)
and specifically for DNS take a look at here where you can find a lot of examples.
2] Alternatively you can use the built-in socket
module:
import socket
info = socket.getaddrinfo('a_domain', a_port)
socket.gethostbyname('a_domain') # but this will give only the ip
3] Finally you can use dnspython .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.