What Is the .bashrc File in Linux?
The .bashrc file is a shell script that runs every time...
The ping command in Linux checks if a host or IP address is reachable by sending ICMP packets. While it’s useful for testing basic connectivity, it cannot check whether a specific port is open. This is because the ping command doesn’t interact with transport layer protocols like TCP or UDP. To check the status of a specific port, we need tools designed to probe ports directly.
In this guide, we’ll show how to use Linux tools like telnet, nc (netcat), and nmap to test if a port is open, closed, or filtered. These tools help troubleshoot network issues and verify that services, such as SSH or web servers, are running properly.
Telnet in Linux is a command-line tool that lets you connect to a remote system and interact with it over the network. You can use it to check if a specific port is open on a server. To do this, run the following command:
telnet [address] [port-number]
Here, replace [address] with the domain name or IP of the server, and [port-number] with the port you want to test. For example, the command below tests if HTTPS (port 443) is open on ultahost.com:
telnet ultahost.com 443
If the port is open, Telnet will connect successfully:
However, if the specified port is closed or blocked, you’ll see a connection error message.
Experience Ultahost’s Cheap Linux VPS!
Experience Ultahost’s affordable Linux VPS plans with full customization, rock-solid performance, and built-in security. Enjoy nonstop uptime backed by proactive support!
Netcat, or nc, is a powerful command-line tool used for reading and writing data across network connections using TCP or UDP. It’s often used to check if a specific port on a server is open. To test a port with Netcat, use the following command:
nc -vz [address] [port-number]
Here, the -v option enables detailed output so you can see what’s happening, and the -z option tells Netcat to scan the port without sending any actual data.
For example, to test port 443 on ultahost.com, run the command below:
nc -vz google.com 443
The output below demonstrates that Netcat successfully connected to port 443 on google.com. The message confirms that the port is open and reachable. Here, the DNS mismatch warning simply indicates that the IP address’s reverse DNS entry does not exactly match the domain name. This is common and not an error in most cases:
If the port is closed, you see a “connection refused” or “timed out” message.
Nmap is a powerful network scanning tool commonly used for finding open ports and identifying potential security issues. It’s also helpful for checking the status of specific ports on a server. Before proceeding with the command usage, make sure Nmap is installed on your system.
You can use the following syntax to check a single port using Nmap:
nmap -p [port-number] [address]
Replace [port-number] with the port you want to test and [address] with the domain or IP, as shown below:
nmap -p 443 google.com
This command scans port 443 on google.com and shows whether it is open or closed. The output also includes information about the service running on that port and how long the scan took:
To scan multiple ports at once, you can enter a range like this:
nmap -p 20-25 ultahost.com
This command checks ports from 20 to 25, which includes commonly used services like FTP (20, 21), SSH (22), and SMTP (25), and then reports their status:
Read also Exploring the Ping Command in Linux
The curl command primarily sends HTTP or HTTPS requests, but you can also use it to check if a specific port is open by connecting to a web service on that port. The following snippet shows the basic syntax for using the curl command:
curl [protocol]://[address]:[port-number]
For example, you can run the following command to test if port 80 is open on example.com:
curl -I http://example.com:80
The output confirms that port 80 on example.com is open and responding with valid HTTP headers, indicating the web server is active and reachable:
The ping command in Linux helps us verify if a host is reachable; however, it doesn’t check the status of specific ports. For that, Linux offers several practical tools, such as Telnet, Netcat (nc), Nmap, and curl, each serving a unique purpose. Telnet is great for quick connection checks, Netcat offers flexible TCP or UDP probing, Nmap provides detailed port scanning and service detection, and curl works well for testing HTTP or HTTPS ports. In this article, we explained how to ping a port using these methods to effectively diagnose port-related issues and ensure your services are accessible over the network.
Deploy your virtual server with advanced DDoS Protected VPS Hosting and keep your business or online service secure from cyber threats. With UltaHost’s robust firewalls, you can stay online with peace of mind. Enjoy easy management, 24/7 support, and reliable performance perfect for hosting critical applications, websites, or game servers without interruptions.
No, the ping command only checks if a host is reachable by sending ICMP packets. It does not verify the status of specific ports.
It depends on your use case. Telnet and Netcat are ideal for quick connection checks, Nmap is great for detailed scanning, and curl is useful for testing HTTP or HTTPS ports.
Use the command “nc -vz [address] 22”, replacing “[address]” with the domain or IP of the server.
It typically means the port is closed, the service isn’t running, or a firewall is blocking the connection.
Yes, this occurs when the IP address’s reverse DNS doesn’t exactly match the domain name. It’s common and not usually an error.
The “-I” option tells curl to fetch only the HTTP headers, which helps confirm if a web server is responding on the target port.
Some commonly used ports include HTTP (80), HTTPS (443), SSH (22), FTP (21), and SMTP (25).
Experience Ultahost’s Cloudflare VPS Hosting!
UltaHost’s managed VPS Cloudflare delivers fast, secure, and reliable performance. The Cloudflare CDN enhances website speed, blocks threats, and ensures seamless traffic distribution.