- How to ping IP and port from Windows or Linux
- Ping IP and port using Telnet
- Install Telnet on Linux
- Install Telnet on Windows
- Ping IP and port with Telnet example
- Ping IP and port using Nmap
- Install Nmap on Linux
- Install Nmap on Windows
- Ping IP and port using Nmap
- Ping IP and port using PowerShell
- Summary
- How to Ping a Specific Port Number
- Ping specific port with Nmap
- Using telnet to ping a specific port on remote server
- Why there is no response from the port?
How to ping IP and port from Windows or Linux
One of the things I do the most when troubleshooting deployments of services exposing data to the internet is pinging the IP and port where the service is supposed to be alive. In this tutorial, I will show you how to ping IP and port on Linux and Windows.
I think most system administrators know the commands for this, but if you like me normally don’t work like an IT admin (at least not anymore) I tend to forget the commands. Due to that, I have written this article as a reference for myself but also for everyone else, who is in need of pinging services they expect at a location.
Often it’s enough to just ping an IP to validate that you got “life” on the server. However if you like me often got many services running on one server (often when using Docker), I need to ping the specific port number on the server. One of the Kubernetes clusters I manage is running more than 100 services and here I use it a lot.
In this article/reference post, I will show you how to ping IP and port on your Windows or Linux machine using different commands in the terminal (CLI).
Ping IP and port using Telnet
This is my favorite when working on both Windows and Linux. I also think that it’s the easiest one to use and it’s called Telnet. You can with a simple command using Telnet ping IP and port on the remote server you would like to check.
If you want to, you can also use a domain instead of the IP. A domain is often easier for humans to remember instead of numbers to multiple different servers locally or externally.
Below are the commands to ping IP and port on a server using Telnet:
As I mentioned above, you can use Telnet on both Windows and Linux computers/servers which makes it a great choice for most sys-ops.
On most computers, telnet is not installed by default. If you get the annoying error “telnet: command not found”, you have to install Telnet on the machine using the commands below:
Install Telnet on Linux
If you are working on a Linux Server or Desktop, you can use the below command to install Telnet on that machine:
Install Telnet on Windows
By default, Telnet is not an enabled Windows Feature. If you run Telnet on your computer in a Command Prompt, you will get the following error: “Telnet is not recognized as an operable program or batch file.”. So – to install Telnet on Windows, you have to do the following:
- Click on Start.
- Select Control Panel.
- Choose Programs and Features.
- Click Turn Windows features on or off.
- Select the Telnet Client option.
- Click OK.
A dialog box appears to confirm installation when it’s done. The telnet command should now be available in your Command Prompt. Remember to restart your CMD window.
Ping IP and port with Telnet example
Let’s check out how Telnet works. This website is running at IP: 172.67.161.26 – this is the public IP address of the website to which the domain is mapped to.
By default, all requests are redirected to HTTPS (port 443) if a request is made at port 80. This means that the server accepts connections on port 80 too – let’s try and ping both ports:
$ telnet 172.67.161.26 80 Trying 172.67.161.26. Connected to 172.67.161.26. Escape character is '^]'. $ telnet 172.67.161.26 443 Trying 172.67.161.26. Connected to 172.67.161.26. Escape character is '^]'.
That went well. We got connected and could see that the server is responding on both ports. This simply means that the service on the port is up and running.
If you would like to escape out of the Telnet utility when connected, you can use “CTRL + ] ” or the “q” command.
Ping IP and port using Nmap
Another well-used tool is Nmap. In Nmap, you can ping a port by using the “-p” option including the IP or domain you would like to scan.
A heads up – be aware of legal issues!
“When used properly, Nmap helps protect your network from invaders. But when used improperly, Nmap can (in rare cases) get you sued, fired, expelled, jailed, or banned by your ISP.” – Nmap website.
If you get an error telling you that Nmap is not available on your computer/server, you would have to install it.
Install Nmap on Linux
To install Nmap on your Linux machine, you can use the below command:
Install Nmap on Windows
Not as simple as Linux, but it’s still easy to use the official installer from Nmap’s website. Go to this page: Download Nmap and look under the Windows Binaries for the latest available installer file.
Once the installer has completed installing, you are now ready to use Nmap on your Windows computer.
Ping IP and port using Nmap
Let’s try to ping a website at IP “172.67.161.26” on the global internet at the default HTTPS port – 443. If you test this yourself, then don’t use that IP. Cloudflare is protecting the website and will block your access and in the worst-case ban your IP from their global network. Only do this at IPs you own or services that won’t do any damage to others.
C:\Users\christian>nmap -p 443 172.67.161.26 Starting Nmap 7.92 ( https://nmap.org ) at 2022-02-10 06:50 Romance Standard Time Nmap scan report for 172.67.161.26 Host is up (0.028s latency).
Well, once again the port is returned as open on the server. This means that there is a service accepting data at port 443, which was just verified by Nmap.
Ping IP and port using PowerShell
Normally when I’m not on my own machines, which means I’m working on production servers not related to my own business/platform and it’s a Windows Server Environment, I always use PowerShell to ping IP and port.
A great thing about PowerShell is that you can use the methods in scripts running automated stuff in the background or during the setup of service or multiple services. A great thing if deploying with PowerShell would be to check if the ports were active after deployment and return a status to the terminal.
In PowerShell, we got something called Test-NetConnection which is a command where you specify either an IP or a domain followed by the port you would like to ping.
PS C:\Users\christian> Test-NetConnection -p
Below is an example of what this would look like on a local network:
Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. PS C:\Users\christian> Test-NetConnection 192.168.1.1 -p 80 ComputerName : 192.168.1.1 RemoteAddress : 192.168.1.1 RemotePort : 80 InterfaceAlias : Wi-Fi SourceAddress : 192.168.1.68 TcpTestSucceeded : True
In the test above you can see that the TCP call to my gateway at home succeeded at port 80. If you can’t get through to the service you will status False in TcpTestSucceeded.
Summary
In this quick article on how to ping IP and port using different tools on Windows or Linux machines, we learned how we can use the terminal to check if a given port is open and accepting requests.
If you got any issues, questions, or suggestions, please let me know in the comments below. Happy pinging!
My name is Christian. I am a 27-year-old pragmatic software engineer with a passion for .NET, Cloud, and Containers. In my spare time, I share my knowledge and love teaching other people about tech.
How to Ping a Specific Port Number
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 (157.240.24.20) 56(84) bytes of data. 64 bytes from edge-star-shv-01-sin2.facebook.com (157.240.24.20): icmp_seq=1 ttl=51 time=307 ms 64 bytes from edge-star-shv-01-sin2.facebook.com (157.240.24.20): 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.
Once you have made sure that you have Nmap installed, you can use it in the following manner to ping a port:
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 (157.240.24.35) Host is up (0.49s latency). Other addresses for facebook.com (not scanned): 2a03:2880:f10c:83:face:b00c:0:25de rDNS record for 157.240.24.35: 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:
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 (157.240.24.35) Host is up (0.34s latency). Other addresses for facebook.com (not scanned): 2a03:2880:f139:183:face:b00c:0:25de rDNS record for 157.240.24.35: 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:
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
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:
Once you have Telnet, you can use it to connect to a specific port of a remote system.
If it’s successful, you should see an output like this:
telnet facebook.com 443 Trying 157.240.24.35… 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.