Link to home
Start Free TrialLog in
Avatar of NetRock6
NetRock6Flag for Canada

asked on

Python: DNS Servers

Hi..
in a python script how can i get all the ip address of  the DNS servers on the network.

Thank you for your help.
Avatar of David Favor
David Favor
Flag of United States of America image

You can just script a command line utility like dig.

And to get all IPs on a network... You must have a starting point, like an IP range.

Then you must determine what constitutes an IP.

By your question, seems like you may be looking for certain services active on certain IPs.

For this you'd use nmap or netcat with the -z option.

Best to describe what you mean by an IP, then someone can assist.

And... highly unlikely you will do this in Python. Rather you'll run some command line tool which does the work for you, so this code will be independent of Python.
Avatar of noci
noci

You would need the DNS resolve library: (and possibly more)

Described here
Source:
http://www.dnspython.org/
Examples:
http://www.dnspython.org/examples.html
https://www.adampalmer.me/iodigitalsec/2014/11/21/performing-dns-queries-python/


To find the nameservers for a domain you need to ask the NS records.
Or use some AXFR zone transfer fr a known domain.

If you mean to find listeners on port UDP:53.
then you need to do queries to all IP addresses port 53.. Which is a bit more involved. Like enumeratings over all addresses and ask for correct info.
Avatar of NetRock6

ASKER

Thank You for your great help.
i saw the link noci has posted this morning. It seems very complicated and I am certainly running out of time.... Therefore, I found another way but i need help to finish it off here it is the link

Thank you again.
ASKER CERTIFIED SOLUTION
Avatar of noci
noci

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great Thanks noci.