What is the best way to scan (using OS X, GUI/Terminal app), for ip's on a local subnet that have a domain name?

Thanks!

link|improve this question
feedback

1 Answer

up vote 1 down vote accepted

If you don't want to actually check if the hosts exist, is to just loop through the IP addresses and do a reverse lookup. The following recipe works on Linux and FreeBSD; I don't know how the host program on Mac OS X behaves:

for x in $(seq 1 254); do
    host 10.0.0.$x || echo "no hostname for $x"
done

You can also use nmap to discover what hosts are up, do a reverse DNS lookup on the hosts that it finds, and then filter on that. nmap has a bunch of options to fine tune the output, but perhaps start with

nmap -sP -R '10.0.0.*' -oN outfile

Or use -oX for XML output that you can process more deterministically. Or combine it with a call to host.

link|improve this answer
nmap's default DNS resolution behavior is "sometimes", though I don't know how that's defined. nmap -R forces to always resolve hostnames. – maik Jan 11 '10 at 20:07
Thanks! nmap + doing a host on the IP worked perfectly. – haroldthehungry Jan 11 '10 at 21:21
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.