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
add comment

5 Answers 5

up vote 27 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
add comment

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
add comment

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
add comment

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. –  George Garside Dec 28 '13 at 22:59
add comment

Type the command

  arp -a

This will show you all connections one by one.

share|improve this answer
add comment

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.