32

I have two Macs on the same network, both plugged into my internet router. I have screen-sharing set up on one of them, so I can connect to it using command-K in the Finder with a vnc:// URL, and that works great.

My router assigns IP addresses using DHCP, which in general is a good thing, but it means if a machine gets restarted or a DHCP lease gets renewed, I don't know what IP address to connect to (without walking over to the other machine to find out).

Surely my Mac already knows the IP address of my other Mac: in the Finder, I can see my other Mac's name and icon/type in the sidebar! Unfortunately, Get Info doesn't display the IP address, or anything else useful about it.

How can I find out the IP address of my other Mac, perhaps using Zeroconf/Bonjour? I'm fine with a command-line solution, if there's a simple one.

EDIT: I'm running Lion, and I think that OS X screen sharing broadcasts a Bonjour service announcement for it, but Lion's connect-to-server dialog box doesn't take advantage of it. If this is something Mountain Lion does, knowing that would be helpful, too!

2
  • Ping its network name and it will return its IP. (E.g. ping other-computer’s-name)
    – Alex
    Oct 9, 2012 at 5:17
  • Alex: Yeah, but the problem is how to get its hostname, if I only know its Zeroconf broadcast name (which is not the same).
    – Ken
    Oct 11, 2012 at 3:19

7 Answers 7

44

Your computers should be accessible as computer-name.local, e.g. Kens-Computer.local or something like that, so depending on what you're trying to do, you might be able to just use that name rather than the IP.

So you can just type vnc://Kens-Computer.local in the 'Connect to' window. You can see the computer's network name if you go to the Sharing preference pane in System Preferences. It's at the top of the page, with a message like "Computers on your local network can access your computer at: Kens-Computer.local"

Make sure you include the ".local" suffix to get the Bonjour IP, otherwise your DNS look-up might auto-append some other hostname suffix (depending on your network/DHCP configuration) or simply fail to find the right host.

If you really want to get the IP though, here's a couple of options:

Bonjour / dns-sd

You can use Bonjour directly via commands like the DNS Service Discovery tool (dns-sd). Try the following in the Terminal application:

% dns-sd -q computer-name
DATE: ---Tue 09 Oct 2012---
18:13:39.209  ...STARTING...
Timestamp     A/R Flags if Name                             T   C Rdata
18:13:39.210  Add     2  4 Computer-Name.local.             1   1 10.1.1.141

The dns-sd tool can do quite a bit, e.g. if you want to list all local VNC services (at least the ones advertised via Bonjour). VNC services are advertised as "_rfb" in mDNS/Bonjour:

% dns-sd -B _rfb local

Ping

Or you can just ping it, which will show the IP in the output (and is just using Bonjour/mDNS to find the IP).

% ping computer-name.local
PING computer-name.local (10.1.1.141): 56 data bytes
64 bytes from 10.1.1.141: icmp_seq=0 ttl=64 time=0.066 ms
2
  • This is a fairly complete answer, and helped me figure it out. The missing piece of the puzzle was that I need to go to the Sharing control panel on that Mac to find out exactly what it thinks the name is -- it replaces spaces and non-Latin characters, so the "name" I see in the Finder, or from dns-sd, isn't the "name" I need to use with ping or a vnc:// URL. I haven't found a way to figure this out from over the network yet, which is strange.
    – Ken
    Oct 9, 2012 at 15:43
  • @Ken: I had the same problem. Try looking at the zone file output and the SRV record. I found that using service type _rfb worked well to display all the macs with screen sharing enabled on my network. Try: dns-sd -Z _rfb or dns-sd -Z _rfb local | grep SRV
    – TrinitronX
    Jun 18, 2013 at 17:35
11

Open Terminal and type: arp -a it will list all the computers on the network and (usually) the host names.

2
  • This command displays 4 entries for me -- my cable modem, my router, my wifi base station, and the strange entry "? (192.168.15.255) at ff:ff:ff:ff:ff:ff" -- but not my other Mac.
    – Ken
    Oct 9, 2012 at 6:28
  • The 255 address is the subnet mask. Try doing ping -c5 192.168.15.255 then running arp -a.
    – daviesgeek
    Oct 9, 2012 at 6:44
2

You can login to the router and look for DHCP Table. It will list all connected devices along with their MAC and IP addresses.

But to avoid this issue altogether, why don't you setup DHCP Reservations through your router? Through that, you can assign a certain MAC address to a specific IP. That way your DHCP IPs remain constant.

The steps necessary to achieve that will depend on the router brand and model.

1
  • My router doesn't support DHCP static leases, and even if it did, I don't think I'd want that. I consider it a feature that I don't need any special config for any of my networking hardware, so I can do a "reset all" if it goes crazy (or replace it with a new one). I have enough to keep track of!
    – Ken
    Oct 11, 2012 at 3:29
1

An alternative is you can log into your router on your browser to see the devices on the network and their IP address. On my linksys, I go to 192.168.1.1, click on status then local network and then DHCP Client table. It shows every device on the network and it's IP address.

You can see your router IP if you check your IP settings, as it will be stated as DHCP-Server or Router.

1

arp -a should give you all the devices within your network.

From man arp:

arp -- address resolution display and control

The arp utility displays and modifies the Internet-to-Ethernet address translation tables used by the address resolution protocol (arp(4)). With no flags, the program displays the current ARP entry for hostname. The host may be specified by name or by number, using Internet dot nota- tion.

-a The program displays or deletes all of the current ARP entries.

0

To find ip address on MAC , follow the below steps :

  1. Launch the Terminal located in /Applications/Utilities/
  2. Type the following command:

    ifconfig |grep inet.*broadcast
    

If you want to find an external ip address visit http://www.ip-details.com/ or http://www.whatismyip.com/.

0

Head to System Preferences > Sharing and check your Local Hostname.

This should be something like Mac-Mini.local. You can use this instead of an IP to reference the computer on your network.

Safari address bar will take an address and port such as: Mac-Mini.local:8080

2
  • But what if one cannot/ doesn't want to open Mac-mini, which I feel is the question aims to do here
    – anki
    Sep 27, 2019 at 7:26
  • 1
    @ankii Fair, but I was searching for "how to find Mac IP" etc. because I thought that was the only option. I think a lot of people might prefer finding their Local-Hostname.local once, then use it going forward.
    – pkamb
    Sep 28, 2019 at 1:58

You must log in to answer this question.

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