Ping is probably the most used tool for checking the network connection to a remote system. Using ping is very easy. You just use the command ping together with the IP address or URL of the remote server.
ping faebook.com PING faebook.com (184.108.40.206) 56(84) bytes of data. 64 bytes from edge-star-shv-01-sin2.facebook.com (220.127.116.11): icmp_seq=1 ttl=51 time=307 ms 64 bytes from edge-star-shv-01-sin2.facebook.com (18.104.22.168): icmp_seq=2 ttl=51 time=225 ms
But what is the default port for the ping command? The answer is none.
Ping is based on ICMP, not TCP or UDP and ICMP protocol doesn’t have port numbers.
So how do you ping a specific port number of the remote server?
You cannot do that with the ping command. However, there are other tools that allow you to ping specific TCP or UDP ports.
Let me show you a couple of such tools and how to use them for pinging a given port number.
Ping specific port with Nmap
Nmap is a network scanning tool. While you can do a lot with Nmap, I’ll show you how to use it for pinging a specific port.
But first, make sure that you have Nmap installed on your system. On Debian/Ubuntu based distributions, you can use the command below to install Nmap.
sudo apt install nmap
Once you have made sure that you have Nmap installed, you can use it in the following manner to ping a port:
nmap -p 443 facebook.com
The output will be something like this:
Starting Nmap 7.60 ( https://nmap.org ) at 2019-01-07 10:40 IST Nmap scan report for facebook.com (22.214.171.124) Host is up (0.49s latency). Other addresses for facebook.com (not scanned): 2a03:2880:f10c:83:face:b00c:0:25de rDNS record for 126.96.36.199: edge-star-mini-shv-01-sin2.facebook.com PORT STATE SERVICE 443/tcp open https Nmap done: 1 IP address (1 host up) scanned in 10.35 seconds
As you can see in the output, the server is up and it responded that the port number 443 of type TCP is open.
If you want to scan more than one ports, you can do that as well. For example, you can provide a range of port numbers like this:
nmap -p 80-88 facebook.com
The output will provide information on each individual port:
Starting Nmap 7.60 ( https://nmap.org ) at 2019-01-07 10:48 IST Nmap scan report for facebook.com (188.8.131.52) Host is up (0.34s latency). Other addresses for facebook.com (not scanned): 2a03:2880:f139:183:face:b00c:0:25de rDNS record for 184.108.40.206: edge-star-mini-shv-01-sin2.facebook.com PORT STATE SERVICE 80/tcp open http 81/tcp filtered hosts2-ns 82/tcp filtered xfer 83/tcp filtered mit-ml-dev 84/tcp filtered ctf 85/tcp filtered mit-ml-dev 86/tcp filtered mfcobol 87/tcp filtered priv-term-l 88/tcp filtered kerberos-sec Nmap done: 1 IP address (1 host up) scanned in 4.49 seconds
You may also use the port name instead of the port number:
nmap -p https facebook.com
The output remains the same as the previous command.
If you want to specifically ping the TCP port, you can specify that as well:
nmap -p 443 -sT facebook.com
For UDP port, you can use
nmap -p 443 -sU facebook.com
Nmap is not the only tool. You can use some other tools as well.
Using telnet to ping a specific port on remote server
Telnet is a remote connection tool similar to SSH however SSH is more secure by design than Telnet.
Before using Telnet, you should make sure that it is installed. On Debian/Ubuntu, you can use this command to install Telnet:
sudo apt install telnet
Once you have Telnet, you can use it to connect to a specific port of a remote system.
telnet facebook.com 443
If it’s successful, you should see an output like this:
telnet facebook.com 443 Trying 220.127.116.11… Connected to facebook.com. Escape character is '^]'.
You can close the connection using the keyboard shortcut Ctrl+] or simply press Ctrl+C.
Why there is no response from the port?
All the examples I showed so far had a successful response. But what if there is no response. What does it mean?
There could be a few possible reasons why I port may not respond.
- There are no services listening to the port so there is nothing that will respond.
- A firewall is blocking the incoming traffic on the specific port.
- There is actually a network connection issue between you and the server in question.
I hope you liked this tutorial and learned how to ping a specific port number. If you have any questions or suggestions, please leave a comment below.