Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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!

share|improve this question
    
Ping its network name and it will return its IP. (E.g. ping other-computer’s-name) –  Alex Oct 9 '12 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 '12 at 3:19
add comment

4 Answers

up vote 13 down vote accepted

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
share|improve this answer
    
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 '12 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 '13 at 17:35
add comment

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/.

share|improve this answer
add comment

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

share|improve this answer
    
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 '12 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 '12 at 6:44
add comment

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.

share|improve this answer
    
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 '12 at 3:29
add comment

Your Answer

 
discard

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.