There are plenty of network monitoring tools you can find in the Linux ecosystem, that can generate for you a summary of the total number of devices on a network including all their IP addresses and more.
However, sometimes what you actually need may be a simple command line tool that can provide you the same information by running a single command.
This tutorial will explain you how to find out all live hosts IP addresses connected to a given network. Here, we will use Nmap tool to find out all IP addresses of devices connected on a same network.
Suggested Read: 29 Examples of ‘Nmap’ Commands for System/Network Administration
The Nmap (short form for Network Mapper) is an open source, powerful and a very versatile command line tool for exploring networks, perform security scans, network audit and finding open ports on remote machine and so much more.
In case you do not have Nmap installed on your system, run the appropriate command below for your distribution to install it:
$ sudo yum install nmap [On RedHat based systems] $ sudo dnf install nmap [On Fedora 22+ versions] $ sudo apt-get install nmap [On Debian/Ubuntu based systems]
Once you have Nmap installed, the syntax for using it is:
$ nmap [scan type...] options {target specification}
Where the argument {target specification}, can be replaced by hostnames, IP addresses, networks and so on.
Therefore to list the IP addresses of all hosts connected to a given network, first of all identify the network and its subnet mask using the ifconfig command or ip command like so:
$ ifconfig OR $ ip addr show
Next, run the Nmap command below:
$ nmap -sn 10.42.0.0/24
In the command above:
-sn
– is the type of scan, which means a ping scan. By default, Nmap performs port scanning, but this scan will disable port scanning.10.42.0.0/24
– is the target network, replace it with your actual network.
For a comprehensive usage information, make an effort to look into Nmap man page:
$ man nmap
Else, run Nmap without any options and arguments to view a summarized usage information:
$ nmap
In addition, for those interested in learning security scanning techniques in Linux, you can read through this practical guide to Nmap in Kali Linux.
Well, that’s it for now, remember to send us your questions or comments through the response form below. You can as well share with us other methods for listing the IP addresses of all devices connected to a given network.