Super User is a question and answer site for computer enthusiasts and power users. 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

I'm trying to resolve an IP address like to a computer name like "JohnsMac". I want to be able to get the local machine name for an internal IP address I know.

What command will return the machine name on OS X?

share|improve this question

Try nslookup:

#: nslookup

This requires that you have nslookup point to a DNS server that knows how to make this resolution. In my personal network, I use my DD-WRT router as a DNS relay and set it to resolve requests for hosts on the internal network (the 192.168.x.x net).

The other thing I can think of is to edit the file located at:

#: /etc/hosts

You have to be root to edit it. Then you flush your DNS cache by running:

#: sudo dscacheutil -flushcache

This will resolve IP addresses to hostnames and vice versa locally on your Mac, so an DNS server is not required. There are some big caveats to how this works though so read the man page for the hosts file:

#: man hosts

Since the 'nslookup' and 'host' commands ignore the hosts file, you have to use other commands to resolve using the hosts file, for example:

#: traceroute


#: dscacheutil -q host -a ip_address
share|improve this answer

In OS X Terminal, just ssh into the admin user.

Here are some example commands to use in the terminal, although there are multiple ways to ssh

ssh adminusername@IPADDRESS


ssh -l[root] IPADDRESS 

Here's an example of using this, with the output


The authenticity of host ' (' can't be established.

RSA key fingerprint is d0:xx:27:xx:4b:xx:37:fb:xx:4a:4b:xx:2e:xx:ea:xx.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '' (RSA) to the list of known hosts.


Last login: Fri Feb 24 12:32:49 2012 from

x-surgeryCPU:~ cadmin$ 
share|improve this answer

For more info, you can use (the free) nmap:

share|improve this answer

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.