Search
Close this search box.

How to perform port scan using Nmap on Ubuntu 20.04

Table of Contents

How to perform port scan using Nmap on Ubuntu 20.04

 

Port scanning can identify open network ports, as well as available services on that particular network, providing security experts with insight into potential vulnerabilities on that network. 

 

 

Configure VPSie cloud server

 
  1. Sign in to your system or register a newly created one by logging in to your VPSie account. 
  2. Connect by SSH using the credentials we emailed you.
  3. Once you have logged into your CenOS instances and update your system.

 

apt-get update && apt-get upgrade -y

 

Check that your Ubuntu 20.04 system is fitted with the NMAP port scanning tool before you begin. For installation details, Click Here.

 

So let’s get started,

 

 

Check all open TCP ports on remote host 1.1.1.1

# nmap 1.1.1.1

 

Scan all TCP and UDP ports on remote host 1.1.1.1

# nmap -sUT 1.1.1.1

 

The following command will scan remote host 8.8.8.8, TCP port 22,

# sudo nmap -p 22

 

Scan remote host 8.8.8.8, UCP port 22,

# nmap -sU -p 22 1.1.1.1

  

Check the TCP and UDP ports of a remote host 1.1.1.1,

# nmap -sUT --open 1.1.1.1

 

Check the TCP ports on your Ubuntu system,

# nmap localhost

 

I hope you have found this article useful, and I hope you have gotten some information from it.

 

Learn more about it

 

In today’s world, web servers are an essential part of our daily lives. They host websites, web applications, and other online services that we interact with daily. While web servers are necessary, they can also be vulnerable to attacks from malicious actors. One way to identify vulnerabilities in web servers is through port scanning.


A port scanner is a tool used to scan a computer or network for open ports. Open ports can be used by attackers to gain unauthorized access to a system. In this article, we will explore how to perform a port scan on Ubuntu using the Nmap tool.

Before we begin, it is essential to understand that port scanning is a sensitive process and should only be performed on systems that you own or have explicit permission to scan.


Step 1: Install Nmap
The first step in performing a port scan on Ubuntu is to install the Nmap tool. Nmap is a free and open-source port scanner that is available for Linux, macOS, and Windows. To install Nmap on Ubuntu, open the terminal and run the following command:

 

CSharp
sudo apt-get install nmap


Step 2: Identify the target
Once you have installed Nmap, you need to identify the target system you want to scan. In our case, we will assume that the target system is a web server with an IPv4 address of 192.168.1.100.


Step 3: Host Discovery
Before we can start scanning the ports on the target system, we need to perform host discovery to ensure that the target system is alive and reachable. To do this, we will use the following command:


nmap -sn 192.168.1.100


The “-sn” option tells Nmap to perform a ping scan, which checks if the target system is alive. If the target system is reachable, you will see a message indicating that the host is up.


Step 4: Port Scanning
Now that we have confirmed that the target system is alive, we can proceed to scan its ports. To do this, we will use the following command:

CSS
nmap -p- 192.168.1.100


The “-p-” option tells Nmap to scan all the ports on the target system. This can take some time, depending on the size of the target system and the network. To speed up the scan, you can specify a range of ports to scan instead of scanning all the ports.


Step 5: Scan Timing
The speed of a port scan can also be adjusted by specifying the timing of the scan. The default timing is “normal,” but you can specify faster or slower scan timings. To do this, you can use the “-T” option followed by a number between 0 and 5. A higher number means a faster scan, but it may also increase the likelihood of false positives. For example, to perform a fast scan, you can use the following command:


CSS
nmap -T4 -p- 192.168.1.100


Step 6: OS Detection and Service Version
Nmap can also detect the operating system running on the target system and the version of the services running on the open ports. To do this, you can use the “-A” option. This option tells Nmap to perform an OS detection scan and a service version detection scan.

CSS
nmap -A 192.168.1.100


Step 7: HTTPS Nmap.org
In some cases, you may want to scan only specific ports. For example, you may want to scan only the HTTPS port (port 443). To do this, you can use the following command:

 

FAQ

Nmap is a free and open-source network scanner that is used for network exploration, management, and security auditing. It can be used to perform a wide range of tasks, such as port scanning, service enumeration, and vulnerability detection.

o install Nmap on Ubuntu, you can use the following command in the terminal:

csharp
sudo apt-get install nmap

This will download and install the latest version of Nmap from the official Ubuntu repository.

Here are the steps to perform a basic port scan using Nmap on Ubuntu:

  1. Open the terminal and type the following command:
php
sudo nmap <target IP or hostname>

Replace <target IP or hostname> with the IP address or hostname of the target system, you want to scan.

  1. Press Enter and wait for the scan to complete. Nmap will display a list of open ports and services running on the target system.

Yes, Nmap provides a wide range of scan options that can be customized according to your requirements. Here are some common options you can use:

  • -p or --port: Specify the port or port range to scan. For example, sudo nmap -p 80 <target> will scan only port 80.
  • -sS or --syn: Perform a SYN scan, which sends a SYN packet to each target port to determine whether the port is open.
  • -O or --osscan-guess: Perform an operating system detection scan, which attempts to identify the operating system running on the target system.
  • -v or --verbose: Increase the verbosity level of the output. For example, sudo nmap -v <target> will display more detailed output.

Port scanning is a technique used by security professionals and hackers alike to identify vulnerabilities in network systems. While it is not illegal to perform port scanning, it is important to ensure that you have the proper authorization to perform the scan on the target system. Unauthorized port scanning can be considered a violation of the Computer Fraud and Abuse Act and can lead to legal consequences. Always seek permission from the system owner before performing any network scans.

Make a Comment
Share on
Facebook
Twitter
LinkedIn
Print
VPSie Cloud service

Fast and Secure Cloud VPS Service

Try FREE
For a month

The First 1 orders gets free discount today! Try Sign up on VPSie to get a chance to get the discount.