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.

Say that I have two computers connected to the same network. I know that from computer1 and file sharing enabled I can snoop around inside computer2. But say that there is something interesting on computer2, which you access by typing localhost:9091 in safari. (e.g. transmission's web UI). To access that I would have to type in the ip_address_of_computer2:9091 on computer1.

But how do I find out computer2's ip address without using computer2?

share|improve this question
    
DO you know computer2's name? –  Mark Apr 9 '13 at 14:23

6 Answers 6

up vote 35 down vote accepted

Method #1

The easiest way would be to access your network router's administration page. It will have information about any other devices on the network, including IP address.

Method #2

If you know the computer's network name you can ping it in the Terminal. It will return the computer's IP address.

Method #3

If you don't know the computer's network name, there's another trick you can do using ping. Find your IP address and your subnet mask. Both should be visible in the Network preference pane of System Preferences. Line up your IP address and your subnet mask, and replace any 0 values in the subnet mask with 255 in the same relative position of the IP address. For example, if you have the following IP address and subnet mask, respectively:

192.168.1.151

255.255.255.0

The 0 is in the last field of the subnet mask, so you replace the last field of the IP address with 255 and ping it: ping 192.168.1.255

You should get a response with the IP address of any device on the network capable of responding to pings.

Method #4

Last trick is to use the terminal command arp -a. This will show the IP and MAC address of all devices on the network that it knows about.

Last two tricks courtesy of this Macworld article.

share|improve this answer
    
thanks a lot for that –  donkey kong Aug 2 '11 at 14:04
1  
Method # 4 arp -a will work if, and only if, the Mac already successfully probed or was connected to a host. Try yourself by restarting your Mac and displaying the arp table. It will be almost empty. To populate that table you need to run something like a ping scan: nmap -sP 192.168.1.0/24 –  ripat Feb 26 at 14:12
    
For some reason, pinging 192.168.1.255 returns the addresses from all Macs in the network, but none from the Linux machines ?!? Great tip though! –  ssc Mar 7 at 20:57
    
ping SOME-PC -4 to forve the IPV4 resolving. –  Nakilon Aug 3 at 6:13

Type the command

  arp -a

This will show you all connections one by one.

share|improve this answer

If you want to know the name using IP: http://runakay.blogspot.com/2013/12/obtaining-computer-name-from-ip-address.html

share|improve this answer
1  
Welcome to Ask Different! While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. –  grgarside Dec 28 '13 at 22:59

You could also use netstat to show network addresses:

roger.moore@WKSTCAL0141 ~
$ netstat -n

Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    127.0.0.1:11235        127.0.0.1:49184        ESTABLISHED
  TCP    127.0.0.1:49155        127.0.0.1:49156        ESTABLISHED
  TCP    127.0.0.1:49156        127.0.0.1:49155        ESTABLISHED
  TCP    127.0.0.1:49184        127.0.0.1:11235        ESTABLISHED
  TCP    192.168.10.131:445     192.168.10.119:52624   ESTABLISHED
  TCP    192.168.10.131:1433    192.168.10.2:60866     ESTABLISHED
  TCP    192.168.10.131:1433    192.168.10.119:52775   ESTABLISHED
  TCP    192.168.10.131:3389    192.168.10.119:54473   ESTABLISHED
  TCP    192.168.10.131:49154   192.168.10.119:52796   ESTABLISHED
  TCP    192.168.10.131:49182   192.168.10.9:52230     ESTABLISHED
  TCP    192.168.10.131:49247   192.168.10.6:445       ESTABLISHED
  TCP    192.168.10.131:49432   192.168.10.4:1106      ESTABLISHED
  TCP    192.168.10.131:49440   192.168.10.4:1106      ESTABLISHED
  TCP    192.168.10.131:49451   192.168.10.6:1025      ESTABLISHED
  TCP    192.168.10.131:55100   192.168.10.2:445       ESTABLISHED
  TCP    192.168.10.131:64558   192.168.10.20:135      TIME_WAIT
  TCP    192.168.10.131:64559   192.168.10.20:49158    TIME_WAIT
  TCP    192.168.10.131:64566   192.168.10.100:135     TIME_WAIT
  TCP    192.168.10.131:64575   192.168.10.100:59811   TIME_WAIT
  TCP    192.168.10.131:64581   192.168.10.41:139      TIME_WAIT
  TCP    192.168.10.131:64582   192.168.10.3:5357      TIME_WAIT
  TCP    192.168.10.131:64585   192.168.10.61:3910     TIME_WAIT
  TCP    192.168.10.131:64587   192.168.10.65:3910     TIME_WAIT
  TCP    192.168.10.131:64588   192.168.10.9:139       TIME_WAIT
  TCP    192.168.10.131:64589   192.168.10.135:2869    ESTABLISHED
  TCP    192.168.10.131:64593   192.168.10.6:135       TIME_WAIT
  TCP    192.168.10.131:64594   192.168.10.6:1025      TIME_WAIT
  TCP    192.168.10.131:64599   192.168.10.100:59811   TIME_WAIT
share|improve this answer

This script should give you what you are looking for really quickly. This require to have nmap installed. The advantage is that if your host does not reply to ping probes, nmap would still find the host while other tools will not.

#!/bin/bash
i="en1"
cidr=$(while read y; do echo ${y%.*}".0/$(m=0; while read -n 1 x && [ $x = f ]; do m=$[m+4]; done < <(ifconfig $i | awk '/mask/             {$4=substr($4,3); print $4}'); echo $m )"; done < <(ifconfig $i | awk '/inet[ ]/{print $2}'))
myip=`ifconfig $i | grep "inet " | awk 'NR==1 {print $2}'`
echo "sudo nmap -n -T4 -PN -p9091 --exclude $myip $cidr"
sudo nmap -n -T4 -PN -p9091 --exclude "$myip" "$cidr"
share|improve this answer
    
How do you save and run that? –  Dan the Man Oct 14 at 15:08
    
You paste this in TextEditor, and save and name this file "qnmap". You then move this file to /usr/bin (Hold Command+Shift+G, or Finder / Go / Go to folder : /usr/bin). open terminal, type "sudo chmod a+x /usr/bin/qnmap". Type "qnmap" in the terminal and wait for the result. –  Florian Bidabe Oct 15 at 2:48
    
Ok. I get this error: /usr/bin/qnmap: line 2: =en1: command not found It looks like the dollar sign before the i shouldn't be there. –  Dan the Man Oct 15 at 12:51
1  
Sorry Dan, my bad, the line should be : i="en1" –  Florian Bidabe Oct 16 at 3:20
    
Cool. It works good. –  Dan the Man Oct 17 at 16:14

There are a few other tools that have not been mentioned yet for discovering IP address information, assuming you have the host name and you are using mDNS (aka Bonjour in Mac environments). Unless you have configured things differently, your local network names are in the form host-name.local so in your initial example you would be looking for computer2.local

The first:

    dscacheutil -q host -a name <host-name>.local

For example:

    % dscacheutil -q host -a name computer2.local
    name: computer2.local
    ip_address: 10.0.1.6

Another useful tool is dig (try dig google.com for example), which with a few special parameters can be used to query the mDNS nodes of your local network.

    % dig @224.0.0.251 -p 5353 <host-name>.local
    % dig @224.0.0.251 -p 5353 -x <ip-address>

To get just the IP address out of dig you can try:

    % dig +short @224.0.0.251 -p 5353 <host-name>.local
share|improve this answer
    
Good one bu it requires to know the IP address or computer multicastDNS name (.local). –  Florian Bidabe Oct 18 at 22:42
    
BonjourBrowser is a nice GUI application for this. –  Florian Bidabe Oct 18 at 22:43
    
@FlorianBidabe - Why do you say you need to know the IP address to use these commands? These commands return the IP address of the named machine. Yes, it is required to know the name of the target machine to use this method. –  KenB Oct 22 at 6:25

protected by Community Mar 16 at 6:15

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.