How to Ping a Specific Port?

We ping the specific port to find out the status of the service. If the service is not responding, the users ping the port by sending the requests. The requests are sent in packets that evaluate the service’s status. If the service is alive, the requests will be returned, but if the service is dead, the request will not return to the server machine.

The different services are associated with different computer ports, so pinging the specific port is useful in troubleshooting.

This post will list the possible ways to ping a specific port on Linux. The content of the post is as follows:

Let’s start digging into the methods by which we can ping a specific port in Linux!.

Method 1: Using the Netcat Tool

The first method to ping the specific port is the Netcat tool, also known as “nc”. The Netcat tool can be installed on Ubuntu by ruining the command:

$ sudo apt install netcat

On the other Linux distributions, the Netcat tool can be installed:

Fedora$ sudo dnf install nc
RHEL$ sudo yum install nc

After installing the Netcat, we can use the Netcat command by following the general syntax:

$ nc -vz <IP> <Port>

In the above command, replace the “IP” with the IP address of the machine whose port is supposed to troubleshoot. And replace the “Port” with the specified port number. In the command, the v option is used to display the verbose, and z is used to scan the specified port, for example, we will ping port 22:

$ nc -vz 192.168.100.97 22

The port has been pinged, and to explore more about the usage of the “nc” command, use the command:

$ nc -h

All the usage information of the “nc” command will be displayed on the screen.

Method 2: Using the Nmap Tool

Next method to ping the specific port is the Network Mapper or Nmap tool. To use the Nmap tool, ensure it is installed on the computer. If it is supposed to be installed, then install it on Ubuntu-based Linux distribution with the command:

$  sudo apt install nmap

On other Linux distributions, it can be installed with the commands:

Fedora$ sudo dnf install nmap
RHEL$ sudo yum install nmap

When the installation is completed, then follow the below-mentioned general syntax to ping the specific port with the nmap command:

$ sudo nmap -p<Port> <IP>

For example, we will again ping the port 22 with the p option of the nmap command to ping the specific port:

$ sudo nmap -p22 192.168.100.97

Port 22 has been pinged, and to get more information on the ping command, use the command:

$ nmap -h

The help information of the nmap command has been displayed on the screen.

Method 3: Using the Telnet

Using the telnet is also one of the easiest ways to ping a specific network. The telnet utility comes preinstalled on the computer. If the command is not installed, then it can be installed by running the commands:

Fedora$ sudo dnf install telnet
RHEL$ sudo yum install telnet
Ubuntu$ sudo apt install telnet

To use the telnet command for pinging the specific port, use the general syntax:

$ sudo telnet <ip_address> <port_number>

To understand, ping the port 22 with the telnet command:

$ sudo telnet 192.168.100.97 22

That’s all about the method to ping the specific port in Linux.

Conclusion

To ping a specific port in Linux, we can use the tools of nc, nmap, and telnet. All these tools are useful for managing network interfaces. This blog uses all the mentioned network tools to ping the specific port. This will help in troubleshooting the services associated with the specified ports.