Nmap, which can be used for scanning a network, is one of the most popular tools included in Linux. It has been in existence for many years, and is currently one of the preferred tools for gathering information about a network. Nmap can be used by administrators on their networks to find any open ports and the host systems. When performing vulnerability assessments, Nmap is surely a tool not to be missed.
Scanning hosts with Nmap
Getting ready
Most Linux versions come with Nmap installed. The first step is to check whether you already have it by using the following command:
nmap --version
If Nmap exists, you should see output similar to this:
If Nmap is not already installed, you can download and install it from this link: https://nmap.org/download.html.
The following command will quickly install Nmap on your system:
sudo apt-get install nmap
How to do it...
Follow these steps for scanning hosts with Nmap:
- The most common use of Nmap is to find all the hosts online within a given IP range. The default command used takes some time to scan the complete network, depending on the number of hosts in the network.
- The following screenshot shows an example:
- To perform a SYN scan on a particular IP from a subnet, use the following command:
- If SYN scan does not work properly, you can also use Stealth scan:
- To detect the version number of the services running on the remote host, you can perform Service Version Detection scan as follows:
- If you want to detect the operating system running on the remote host, run the following command:
nmap -O 192.168.1.102
- The output here has been truncated:
- If you wish to scan only for a particular port, such as 80, run the command:
How it works...
Nmap checks for the services that are listening by testing the most common network communication ports. This information helps the network administrator to close all unwanted or unused ports and services. The previous examples show how to use port scanning and Nmap as a powerful tool to study the network around us.
See also
Nmap also has scripting features that we can use to write custom scripts. These scripts can be used with Nmap to automate and extend the scanning capabilities of Nmap.
You can find more information about using Nmap at its official homepage:
https://nmap.org/.