Ping Specific Port {in Linux & Windows} | phoenixNAP KB

Introduction

The ping command is a network tool for checking if a remote system is running. In other words, the command determines whether a certain IP address or host is reachable. Ping uses a network layer protocol called Internet Control Message Protocol (ICMP) and is available on all operating systems.

On the other hand, port numbers belong to transport layer protocols, such as TCP and UDP. Port numbers help identify where an Internet message or other network message is forwarded when it arrives.

In this tutorial, you will learn how to ping a port on Windows and Linux using different tools.

Prerequisites

  • A Linux or Windows system
  • Command Line
  • Access

  • An account with sudo/admin

privilegesCan a specific port be pinged?

Network devices use ICMP to

send error messages and information about whether communication with an IP address is successful or not. ICMP differs from transport protocols in that ICMP is not used to exchange data between systems

.

Ping uses ICMP packets, and ICMP does not use port numbers, which means that a port cannot be pinged. However, we can use ping with a similar intention: to check if a port is open or not.

Some network tools and utilities can simulate an attempt to establish a connection to a specific port and wait to see if the destination host responds. If there is a response, the destination port is open. Otherwise, the destination port closes or the host cannot accept a connection because there is no service configured to listen for connections on that port.

How to ping a specific port on Linux?

You can use three tools to

ping a port on Linux: Telnet

  • Netcat (nc
  • )

  • Network Mapper (nmap)
  • See our tutorial on how to use the ping command on Linux for information on additional ping options and variations on Linux. Ping a specific port using

Telnet

Telnet

is a protocol used for interactive communication with the destination host over a virtual terminal connection

.

1. To check if telnet is already installed, open a terminal window and enter telnet.

2. If telnet

is not installed, install it using the following command

For

  • CentOS/Fedora: yum -y
  • install telnet

  • For Ubuntu: sudo apt install telnet

3. To ping a port using telnet, enter the following command in the terminal: telnet

<address> <port_number>

The syntax <address> is the domain or IP address of the host, while <port_number> is the port you want to ping.

telnet google.com 443

If the port is open, Telnet establishes a connection. Otherwise, it indicates an error.

4. To exit telnet, press Ctrl + ] and run the q command.

Ping a specific port using

Netcat

Netcat (nc) reads and writes from connections that use the TCP and UDP protocols. This command-line tool can perform many network operations.

1.

To check if netcat is installed

: For

  • Debian, Ubuntu and Mint: type netcat
  • -h

  • For Fedora, Red Hat Enterprise Linux and CentOS: ncat -h

2. If netcat is not installed, run the following command in the terminal:

sudo apt install netcat

3. To ping a port using netcat, type the following:

nc -vz <address> <port_number>

The output informs the user whether the connection to the specified port is successful or not. If successful, the port is open.

Ping a specific port using Nmap Nmap

is a network tool used for vulnerability scanning and network discovery. The utility is also useful for finding open ports and detecting security risks.

1. Check if you have Nmap installed by entering nmap -version in the terminal.

If Nmap is installed, the output informs the user about the version of the application and the platform on which it runs.

2. If there is no Nmap on your system, enter the following command

: For CentOS or RHEL Linux: sudo yum install nmap

  • For Ubuntu or Debian Linux: sudo apt install nmap

3. After Nmap is installed on the system, use the following command to ping a specific port: nmap

-p <port_number> <address>

The output informs the user about the port status and service type, latency, and time to task completion

.

4. To ping more than one port, type nmap -p <number-range> <address>.

The syntax <number range> is the range of port numbers you want to ping, separated by a hyphen.

For example

: nmap -p 88-93 google.com Learn in depth how to use nmap to scan ports with

our guide How to scan and find all open ports with nmap. How

to ping a specific port in Windows? There are two ways to ping a port in Windows: Telnet PowerShell

Ping

a port

using Telnet Before using

  • telnet

, make sure it is turned on:

1. Open Control Panel.

2. Click Programs, and

then click Programs and Features.

3. Select Turn Windows features on or off.

4. Find the Telnet client and check the box. Click OK.

You activated the Telnet client on the system.

After activation is complete, you are ready to ping a port using telnet.

Follow these steps:

1. Look for “cmd” in the start menu. Click the command prompt.

2. In the Command Prompt window, enter

telnet <address> <port_number> The

syntax <address> is the domain or IP address of the host, while <port_number> is the port number you want to ping

.

The output lets you know if the port is open and accessible. Alternatively, a connection error message is displayed.

Ping a port using PowerShell PowerShell

is a text-based shell that comes with Windows by default

.

To ping a port by using PowerShell, follow these steps:

1. Search for “PowerShell” in the start menu. Click the Windows PowerShell application.

2. In the PowerShell Command Prompt window, type

Test-NetConnection <address> -p <port_number>

If the port is open and the connection passes, the TCP test succeeds. Otherwise, a warning message appears stating that the TCP connection failed.

Conclusion

Now you know how to ping and check if a port is open using various networking tools and utilities on Linux and Windows

.

Note that you should not perform TCP probes or scan a system unless you have permission from the owner. Otherwise, their actions may be interpreted as an attempt to compromise security.