26

I have the IP address of a computer on my network but is there a way that with the IP address I can find the name of computer?

For example, if I know the IP address is 192.154.23.60, can I use this IP from my Mac to see the name, such as Jacob's MacBook?

0

5 Answers 5

17

From the Terminal.app (or equivalent) you can use the host command to show the network name of the computer. This returns the name even if it has all sharing settings turned off and thus not showing via Finder.

For example, in my network I get the following (where I know the IP-address and the first part of the returned name is the computer's name)

➜ ~ host 192.168.2.135

135.2.168.192.in-addr.arpa domain name pointer raspberrypi.private.lan.

It depends on the actual name of the computer if the network name is exactly the same, as in your example, I guess it would become Jacobs-MacBook.

3
  • This does not for for me for local servers: On my iPad an app creates a server under say 192.168.0.4:8080, which I can access from my Mac, but neither host 192.168.0.4 nor arp 192.168.0.4 give me a name back.
    – halloleo
    Commented Feb 22, 2017 at 23:16
  • didn't work for me
    – Miguel
    Commented Sep 26, 2017 at 15:51
  • tried it, but did not work for me - using Angry IP scanner I did get the device name though Commented Oct 29, 2018 at 13:51
9

Without further access to the host (e.g. ssh or ARD) and no service running on it (e.g. iTunes Music Sharing/File Sharing) you can't get the computer name based on the IP-address.

The computer name in macOS is not necessarily indentical to the hostname or the Bonjour name! You can simply check this with scutil --get { ComputerName | LocalHostName | HostName }. ComputerName is the user friendly name, LocalHostname is the Bonjour name - both also visible in System Preferences > Sharing - and HostName is the hostname of the device. The hostname is usually related to or used with DNS, NIS, hosts file or similar methods of name resolution. On a newly installed consumer system no hostname is set. ComputerName and LocalHostName are usually derived from the first user's name and the Mac model (e.g. Admin's iMac | Admins-iMac).

Without a name record for the remote Mac in your hosts file or on a DNS-server in your local or a public network neither of the tools mentioned in the other answers (arp, ping, host) can be used to resolve the hostname.

If a known Bonjour service is running on the remote Mac you can get the Computer and the Bonjour name of an IP in a two-step process by retrieving all hosts offering it with dns-sd -Z _nfs._tcp local (the example service here is NFS - other service names can be found here) and pinging all listed Bonjour names until you find the proper IP. As an GUI alternative you can use the Bonjour Browser.

In some cases you can get a name similar to the Bonjour name by entering smbutil status <IP>. The name is the NetBIOS name which is the "all-caps and without allmost all special characters" version of the Computer/Bonjour name.

3

In Terminal I would use arp

  • First make sure you have sent at least one packet to this machine using ping.

    $ ping -c 1 2.2.2.12
      PING 2.2.2.12 (2.2.2.12): 56 data bytes  
      64 bytes from 2.2.2.12: icmp_seq=0 ttl=255 time=0.981 ms  
    
  • Next arp that address.

    $ arp 2.2.2.12
      <host>.<domain> (2.2.2.12) at 0:1c:c4:f4:b8:c7 on en1 ifscope [ethernet]
    
2
  • You're just doing an extra step with the ping+arp combination. arp is just calling the same thing as host to return the hostname.
    – Bert
    Commented Aug 11, 2013 at 14:31
  • didn't work for me
    – Miguel
    Commented Sep 26, 2017 at 15:49
-2

In Finder, go to your computer (which should be listed on the left sidebar under Devices). Then double-click on Network. This will show you all of the other computers on your network that are browsable.

1
  • 3
    That is not what he is asking, he is trying to find the host name from the ip address. just because a mahine is one the network does not mean that it is exposing afp, smb or netfs.
    – hoss
    Commented Aug 11, 2013 at 1:28
-3

Just Ping that ip address with -a option. It will show you the computer name. Example ping -a 192.168.0.1

4
  • 6
    The -a flag means audible (or ring the bell). It has nothing to do with hostnames. Refer to the man page for ping
    – Allan
    Commented Jul 14, 2017 at 10:41
  • 1
    And the flag would have to be set directly after the command: ping -a ...
    – klanomath
    Commented Jul 14, 2017 at 10:43
  • oh yeah sorry man.. Its ping -a ... some time hand makes mistake while mind not. Commented Jul 17, 2017 at 11:29
  • ping -R -v ... should do the trick on mac. Commented Jun 6, 2019 at 9:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .