View IP Addresses of LAN Devices from Command Line in Mac OS

Nov 3, 2016 - 7 Comments

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.

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:

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.

Do you know of another helpful way to to find, locate, and list network connected devices and computers on the same network? Share it with us in the comments!

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS X, Tips & Tricks

7 Comments

» Comments RSS Feed

  1. Jon Ravioli says:

    Great tip.

    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.

  2. junebeetle says:

    Thanks for the very useful tip!

  3. gutgetarnt says:

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

  4. Jonathan says:

    In what kind of situation would you use this? What would you be trying to find out and why? Thanks.

    • Paul says:

      There are many situations this can be useful, from network discovery to connecting to network resources.

      Personally I use this frequently when I need the IP address of a given network device to connect to, particularly other older Macs that often don’t show up in the Network search but you can connect to reliably with SMB by specifying an IP. Same idea with networking to some Windows machines too.

    • Toby says:

      Another great use of this tip is to find the IP address of an IP camera when first setting it up.

  5. bd says:

    sudo arp-scan –interface=eth0 –localnet

    eth0 should be replaced with the interface you are currently using.

    This can be used in unix systems. it will show the IP addresses of all the devices in the local network

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Recent Posts