Ubuntu#
On Ubuntu, you can use the nmap
package to scan online devices in the local network. Here is the installation and usage example:
sudo apt install nmap -y
sudo nmap -sn 192.168.1.0/24
The above commands will list the IP and MAC addresses of all online devices in the local network. In the command:
- The
-sn
option indicates no port scanning, only host discovery is performed. 192.168.1.0/24
represents scanning all hosts in the local network with IP addresses from 192.168.1.X (where X is an integer from 1 to 254). The 24 comes from the cumulative count of the number of 1s in binary when each number separated by "." in the subnet mask is converted, for example, 255.255.0.0 converted to binary is 11111111.11111111.00000000.00000000, which has 16 ones.
After scanning, each device's information is displayed as follows:
Nmap scan report for _gateway (192.168.0.1)
Host is up (0.018s latency).
MAC Address: F8:8C:21:B3:DB:F8 (Unknown)
The above example indicates that the MAC address of 192.168.0.1 is F8:8C:21:B3:DB and it is online.
Windows#
Download nmap
from https://nmap.org/ on Windows, install it, and then refer to the example above for usage.