Get Hostname from IP address/MAC address

6

3

I have a list of IP addresses and MAC addresses connected to my local network, but I need to get the hostnames of each device, is there a command line or terminal (mac) command for this?

Jonathan.

Posted 2010-12-06T21:35:31.147

Reputation: 2 454

Answers

4

The command host IP should do it:

jed@jed-osx:~$ host 4.2.2.2
2.2.2.4.in-addr.arpa domain name pointer vnsc-bak.sys.gtei.net.

As Zoredache mentions in the comments, this is not going to work if DNS isn't set up properly. Of course, if that is the case, then you have very limited options. The only method that I can think of is to connect to the IP and ask it what its hostname is (e.g. if you can ssh to it, you can then perform the hostname command to see what it thinks its name is: ssh user@the-ip-address hostname).

Jed Daniels

Posted 2010-12-06T21:35:31.147

Reputation: 1 166

1That presumes that the reverse DNS is setup and updated. If DNS is not setup or maintained then host won't do anything useful. – Zoredache – 2010-12-06T21:59:26.603

4@Zoredache, presumably if DNS is not set up properly, then there won't be any way to get a host's name from its IP. – nhinkle – 2010-12-06T22:29:43.920