List ALL devices on local network?

Robert Moore picture Robert Moore · Jun 4, 2015 · Viewed 35k times · Source

I have tried arp -a a lot and it has listed some devices, but not all of them. ifconfig shows my ip address and mac address and some other useful information, but it doesn't show all of the devices on the local network. Is there a command that shows all IP addresses?

Answer

Krzysztof Sawicki picture Krzysztof Sawicki · Jun 13, 2015

arp -a will show you only MAC addresses that are stored in local ARP cache and your computer was connected to. When I'm trying to see every device in my local network I have to scan it. For example if you have 192.168.1.0/24 network you can do:

$ for i in `seq 1 254`; do
ping -c 1 -q 192.168.1.$i &
done

You will try to ping every computer in your network. Of course not every computer will answer for ping. This is why you can't rely on ping. Now you need to check ARP cache.

$ arp -a | grep 192.168.1. | grep ether

This command will show you ARP cache filtered only with computers that are in this network and that answered on ARP requests (in 99% cases it will be full list of devices in your network - just remember that ARP entry is not removed immediately when the device disconnects).