Atlantic.Net Blog

How to Check Open Port on a Remote Linux System

Hitesh Jethva
by Atlantic.Net (395 posts) under Tutorials, VPS Hosting
0 Comments

A Port is a logical number assigned to a process running on Linux. Port can be defined as an integer number between 0 to 65535. Ports with numbers 0–1023 are called system or well-known ports, while ports with numbers 49152-65535 are called dynamic, private, or ephemeral ports. If you are a Linux system administrator then you should have the knowledge to find out which ports are open and running on a remote system. There are several ways to find an open port on Linux.

In this post, we will show the most reliable ways to find an open port on a remote Linux system.

Prerequisites

  • A server running Linux on the Atlantic.Net Cloud Platform
  • A root password configured on your server

Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing any Linux operating system with at least 1GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Find Open Port Using Netcat Command

Netcat is a Linux command-line utility used to read and write data across network connections using TCP or UDP protocol. It also allows us to find open ports on a remote Linux system.

By default, the Netcat utility is not included in the Linux system. You will need to install it manually using the package manager.

For Ubuntu and Debian-based operating systems, install the Netcat utility using the following command:

apt-get install netcat -y

For RHEL, CentOS, Fedora, and Rocky Linux operating systems, install the Netcat utility using the following command:

dnf install nc -y

The basic syntax to use the Netcat command is shown below:

nc [-options] [host_name or ip] [port_number]

For example, to check if port 80 is open on the remote host 172.20.10.2, run the following command:

nc -zv 172.20.10.2 80

If port 80 is open on a remote host, you will get the following output:

Connection to 172.20.10.2 80 port [tcp/http] succeeded!

Where:

  • -z : Sets nc to simply scan for listening daemons.
  • -v : Show output in verbose mode.

You can also specify a range of ports to be scanned:

nc -zv 172.20.10.2 40-80

The above command will scan for all ports between 40 and 80.

Find Open Port Using Nmap Command

Nmap is a powerful and very popular command-line utility used to perform network-related tasks. By default, the Nmap utility is not included in the Linux system. You will need to install it manually using the package manager.

For Ubuntu and Debian-based operating systems, install the Nmap utility using the following command:

apt-get install namp -y

For RHEL, CentOS, Fedora, and Rocky Linux operating systems, install the Nmap utility using the following command:

dnf install nmap -y

The basic syntax to use the Nmap command is shown below:

nmap [-options] [HostName or IP] [-p] [PortNumber]

For example, to get a list of all open ports on a remote host 172.20.10.2, run the following command:

nmap 172.20.10.2

You should see all open ports in the following output:

Starting Nmap 7.60 ( https://nmap.org ) at 2022-04-05 14:05 IST
Nmap scan report for vyompc (172.20.10.2)
Host is up (0.000078s latency).
Not shown: 996 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
23/tcp   open  telnet
80/tcp   open  http
7070/tcp open  realserver

Nmap done: 1 IP address (1 host up) scanned in 0.88 seconds

If you want to check if a particular port is open on the remote host, use the -p option:

nmap -Pn -p 80 172.20.10.2

You will get the following output:

Starting Nmap 7.60 ( https://nmap.org ) at 2022-04-05 14:08 IST
Nmap scan report for vyompc (172.20.10.2)
Host is up (0.00011s latency).

PORT   STATE SERVICE
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds

Find Open Port Using Telnet Command

Telnet is another network protocol used to virtually access a remote computer. It also allows you to find open ports on remote systems. You can install it manually using the package manager.

For Ubuntu and Debian-based operating systems, install the Telnet utility using the following command:

apt-get install telnet -y

For RHEL, CentOS, Fedora, and Rocky Linux operating systems, install the Telnet utility using the following command:

dnf install telnet -y

The basic syntax to use the Telnet command is shown below:

telnet [HostName or IP] [PortNumber]

For example, to check if port 22 is open on a remote host 172.20.10.2, run the following command:

telnet 172.20.10.2 22

If port 22 is open, you will get the following output:

Trying 172.20.10.2...
Connected to 172.20.10.2.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.6

If port 22 is not open, you will get the following output:

Trying 172.20.10.2...
telnet: Unable to connect to remote host: Connection refused

Conclusion

In this guide, we have shown how to find an open port on a remote machine using different commands. You can now choose your preferred tool to scan the remote system and find an open port. Try it on VPS hosting from Atlantic.Net!

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

How to Install Apache Solr on Oracle Linux 8
How to Install Apache Cassandra on Oracle Linux 8
How to Install Yarn NPM Package Manager on Oracle Linux 8
How to Install Apache Spark on Oracle Linux 8
How to Install Docker and Docker Compose on Oracle Linux 8

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2008 Lookout Dr,

Dallas, Texas 75044

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources