Find All Devices Connected to Local Network using Nmap

Find All Devices Connected to Local Network using Nmap

There might be cases where you want to determine if unwanted users not using your wireless network or to find all devices connected to your network. Nmap is one of the ways to do that. Nmap is a cross-platform tool that allows to scan networks via command line.

To determine which devices are connected to a local network, first we need to get the IP range of the network. On Linux, we can use ip command.

ip addr show
Find IP address on Linux for Nmap

On Windows, we can use ipconfig command.

ipconfig
Find IP address on Windows for Nmap

In our case, subnet mask is 255.255.255.0 = 24 and network IP range is from 192.168.0.0 to 192.168.0.255.

Now we can run the nmap command to find which devices are connected to the local network:

nmap -sn 192.168.0.0/24

On Linux, this command will show only the IP addresses. Execute the command as superuser to include the MAC address of each device as well.

sudo nmap -sn 192.168.0.0/24

The -sn option means that port scanning will be skipped. In previous Nmap releases, -sn was available as the -sP option.

Find All Devices Connected to Local Network using Nmap

The 2 Comments Found

  1. Avatar
    TheKing2 Reply
    ip -o -f inet addr show | \
    awk '/scope global/ {split($4, a, "/"); \
       print a[1] "/" a[2]}' | \
       while read subnet; do \
          sudo nmap -sn "$subnet"; \
          done | \
          awk '/Nmap scan report/{ip=$NF}/MAC Address:/{print ip, $3}'
    • Avatar
      lindevs Reply

      Thanks. It is a combined command for Linux systems that extracts the subnet of network interface and lists discovered IP addresses and their associated MAC addresses.

Leave a Comment

Cancel reply

Your email address will not be published.