Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question
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"

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.

share|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. – christo16 Jan 11 '10 at 21:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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