Display list of computers on a LAN in Linux

I'm a web dev who is trying to get a better handle on security. I'm trying to figure out a way (on Linux/Debian based distros) to list all computers on the same LAN my netbook is on. I tried "arp -n" but I don't feel it's a complete list, as my iPhone is on the same wi-fi router as my netbook, and that didn't come up. Is there some better way to get a full list of machines that are all sharing the same gateway?


Get nmap. It's the program Trinity used in The Matrix and you can do a scan to find all of the devices that are connected to the LAN you're on and more.

Here's the reference guide.


This is what I use, nmap, and an address using CIDR block notation of the network you want to scan. First you need to install nmap as it may not come pre-installed with you distro. On Ubuntu:

sudo apt-get install nmap

Next figure out your network address by using ifconfig:

ifconfig

ifconfig output for the interface I want to scan:

wlan1     Link encap:Ethernet  HWaddr 00:1f:3b:03:d2:bf  
          inet addr:192.168.1.104  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::21f:3bff:fe03:d2bf/64 Scope:Link
          ...

Use the inet addr and Mask to figure out the network address in CIDR notation, more on CIDR here. The address is:

192.168.1.0/24

Run nmap using -sP parameter, which will scan no further than checking if the host is online:

sudo nmap -sP 192.168.1.0/24

nmap output will look something like this:

Starting Nmap 5.21 ( http://nmap.org ) at 2014-12-09 10:52 EST
Nmap scan report for 192.168.1.1
Host is up (0.013s latency).
MAC Address: -MAC ADDRESS- (Cameo Communications)
...
Nmap done: 256 IP addresses (5 hosts up) scanned in 3.26 seconds

That's it, if you need more help with nmap, see the nmap official documentation, or run:

nmap --help