via CLI

November 3, 2016 •

View IP Addresses Of LAN Devices From Command Line In Mac OS

Paul Horowitznull

Find Local Hardware IP Addresses on LAN

If you need to view the IP addresses of other hardware on the same LAN (Local Area Network) as a Mac, the command line arp tool works quite well. You’ll quickly find other devices IP and accompanying MAC addresses, which can make direct network connections easier and be helpful for many other network and troubleshooting purposes.null

Find Local Device IP Addresses with arp

To get started, launch the Terminal app from /Applications/Utilities/ (or accessed with Spotlight and Command+Spacebar). The arp tool is uses ARP (Address Resolution Protocol) to display and control network address resolution functions. For the purposes we want to achieve here, the most simple use of arp is with an -a flag attached:

arp -a

This will return devices found on the local network, including other Macs, PCs, routers, iPhones, and iPads, displaying both their LAN IP address as well as their individual MAC address. (For the latter, you can help distinguish hardware by matching them up to the MAC address found in MacOS X or in iOS).

An example of arp -a output looks like this:
% arp -a
? (192.168.0.1) at 0:0:ca:1:2:3 on en0 ifscope [ethernet]
? (192.168.0.2) at 68:b8:3d:22:1c:42 on en0 ifscope [ethernet]
? (192.168.0.11) at b4:12:23:5a:d3:6f on en0 ifscope [ethernet]
? (192.168.0.255) at ff:ff:ff:ff:ff:ff on en0 ifscope [ethernet]

How to Find IP Addresses of Devices on a Local Network with ping & arp

If the output doesn’t look up to date, or if it’s missing an IP you believe should be there, ping the broadcast IP (typically the last result of arp -a ending with “.255”), then run arp -a again like so.

First ping the broadcast IP:null

Terminal% ping 192.168.0.255
PING 192.168.0.255 (192.168.0.255): 56 data bytes
64 bytes from 192.168.0.6: icmp_seq=0 ttl=64 time=0.079 ms
64 bytes from 192.168.0.1: icmp_seq=0 ttl=64 time=1.922 ms
--- 192.168.0.255 ping statistics ---
2 packets transmitted, 2 packets received, +6 duplicates, 0.0% packet loss
round-trip min/avg/max/stddev = 0.079/39.404/303.510/75.738 ms

Then run arp -a command again:

Terminal% arp -a
? (192.168.0.1) at 0:0:ca:1:2:3 on en0 ifscope [ethernet]
? (192.168.0.2) at 68:b8:3d:22:1c:42 on en0 ifscope [ethernet]
? (192.168.0.10) at 22:12:bb:a0:3d:fd on en0 ifscope [ethernet]
? (192.168.0.11) at b4:12:23:5a:d3:6f on en0 ifscope [ethernet]
? (192.168.0.255) at ff:ff:ff:ff:ff:ff on en0 ifscope [ethernet]

Note in this example that 192.168.0.10 is a fresh IP compared to the prior results, as that machine just joined the network.

You can ignore the protocol suggestion at the end of the arp results, in this example despite the devices showing as “ethernet”, they’re actually all on a wireless network with wi-fi on the en0 interface.

Do note that you will not see the Macs own IP address or MAC address in this list. If need be, you can find your own IP address through Terminal, System Preferences, or by using an outside service if you’re looking for the external address.

While arp works well enough for most cases, and it has the advantage of being built into all versions of Mac OS X, it may not be sufficient for everyone. For more advanced users, nmap is an even better option for a network discovery tool, but nmap requires installing either directly, compiling through source, or through something like homebrew.

How do I find IP addresses of all other computers on my network?

The above ping and arp trick will find and list all IP addresses of any devices or computers on the network. This means the IP address of any same network connected Mac computers, Windows PC, Linux machines, iOS devices like iPhone and iPad, Android phones and tablets on the same network, even set-top IP enabled boxes like an Apple TV or Playstation will be found, assuming those devices and computers are connected to the same local network as the computer doing the searching.

TIPP:

You should always ping the network broadcast address and then run arp -a for the most up to date list.

That is, unless you have already contacted other network machines, then it will be up to date with hardware.

Every device will show up on the arp list though, not just computers in the networked sense. That means the Windows, Androids, iPhones and iPads too.

sudo arp-scan –interface=eth0 –localnet

This only works to review IPv4 hosts. To view IPv6 LAN hosts, use “ndp -a”.

https://www.lifewire.com/using-netstat-command-on-mac-4176069

https://apple.stackexchange.com/questions/117644/how-can-i-list-my-open-network-ports-with-netstat

networksetup -listallhardwareports
sudo tcpdump -i en0 -n

https://developer.apple.com/documentation/network/recording_a_packet_trace