Open In App

Find All Live Hosts IP Addresses Connected on Network in Linux

Last Updated : 03 Nov, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

As network engineers or penetration testers, we need to find the live hosts on the networks. In today's guide, we are going to see how to find live hosts on the network. We are going to use the nmap tool to find the live hosts on the network.

Nmap (network mapper) is an open-source command-line tool for network exploration and security auditing. Nmap is used to scan the networks using the raw IP packets.

Installation

Now let's see how to install nmap on the different Linux distributions:

For Ubuntu/Debian/Kali Linux systems:

sudo apt-get install nmap

For Arch Linux:

sudo pacman -S nmap

For CentOS:

sudo yum install nmap

For Fedora:

sudo dnf install nmap
Find Out All Live Hosts IP Addresses Connected on Network in Linux

Syntax

Now we have installed the nmap on the system. The syntax for nmap use is:

 nmap  <scan type...>  options  <target>

Here, scan type are the option provided by the nmap. And the target is the IP address or hostname of the network.

Key Options

The following are common options used with Nmap:

Option

Description

-sn

Disable port scan; only perform host discovery.

-sP

Similar to -sn, perform ping scan.

-p

Specify particular ports to scan.

-sV

Attempt to determine the version of services running.

Basic Command Example

Now to find a live host first we need to find the IP address and the subnet mask of the target that means we need to find the IP address and its subnet mask of our network. We can find the IP address by following commands:

ifconfig

or 

ip addr show
Find Out All Live Hosts IP Addresses Connected on Network in Linux

Here in this case the IP of the network is 192.1.1.0 and the subnet mask is 255.255. 255.0 i.e. /24. Now we are going to use the following command of nmap to find the live host on our network.

Here -sn is an option: This option tells the nmap to do not scan port after host discovery of a live host. By default, the Nmap scans all ports on the discovered host.

192.168.1.0/24 is a target: We are going to scan the live host on this target.

 nmap -sn 192.168.1.0/24

In the above output, we can see there are two live hosts. To know more about we can use man command or help command like to follow:

man nmap

and

nmap --help

This is how we can find the live host on our network.

To perform a ping scan, we will use the -sP option. This option is similar to -sn, but clearly shows that the scan is only checking which hosts are up in the specified range.

We are going to perform a ping scan with the following command:

nmap -sP 192.168.1.0/24
img5
GFG

In the above output, the command sends ICMP echo requests to each host in the subnet. If a host responds, Nmap marks it as “up.” It's a quick way to find active devices on a network without scanning for open ports.

To determine what services are running and their versions on open ports, we will use the -sV option for service version detection:

nmap -sV 192.168.1.0/24
img6
GFG

In the above output, we can see the command displays information about the service and its version.

To also scan specific ports such as SSH (port 22) and HTTP (port 80), we will simply use the -p option with the nmap command as shown in the following command:

nmap -p 22,80 192.168.1.1


image7
GFG

In the above output, the command solely scans ports 22 and 80 of the specified host.

Conclusion

The Nmap command helps you to identify live hosts on a network is a straightforward process. By understanding how to use it, you can effectively map out the devices connected to the network.


Next Article
Article Tags :

Similar Reads