Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a unix command to retrieve NS records from domain?

I am looking for a way to get the primary and secondary NS records of a given domain name, and the IP addresses associated with them.

Now this kind of information is available from websites like intodns.com, but I am working on a huge list of domains and would like to automate this process with a bash script (probably not the best choice for this...).

I tried nslookup domain.com, which gives me the primary NS IP address.

hostname domain.com returns nothing...

I also tested dig domain.com TYPE NS which doesn't add much info.

At this point I am thinking of a wget of the intodns.com page and parsing the html to get what I need...

Do you know of any better way for doing this?

Thanks a lot!

like image 214
Zenet Avatar asked Oct 10 '10 08:10

Zenet


2 Answers

$ dig example.com NS

works just fine for me. No, it doesn't resolve the IP addresses of the nameservers, but that's not part of the NS record. You'll have to do that yourself. Unlike the output of whois, it's in a standardized format, so it'll be easier to parse.

like image 199
Chris Avatar answered Oct 02 '22 19:10

Chris


nslookup -query=ns <server.com>
like image 39
ghostdog74 Avatar answered Oct 02 '22 19:10

ghostdog74