Why can't I ping the port number? How can I verify that the port number is available?

Why can't I ping the port number? How can I verify that the port number is available?

1. Why can't the port number be pinged?

Ping is a network tool that is often used to test whether the network connection between two computers is normal. Ping uses the Internet Control Message Protocol (ICMP) to send ICMP request messages to the target computer. If the target computer is working properly and connected to the network, it will reply with an ICMP response message. This is a tool commonly used to test network reachability and measure network latency.

However, Ping is not a tool that tests network connectivity by port number. It uses the ICMP protocol instead of traditional port number-based protocols such as Transmission Control Protocol (TCP) or User Datagram Protocol (UDP). Therefore, Ping does not test for a specific port number, but rather tests whether the target computer can respond to ICMP requests.

In summary, ping cannot verify whether the system port number is available. The main reasons are as follows:

  • Different protocols: Ping uses the ICMP protocol instead of the TCP or UDP protocol. System port numbers are usually associated with the TCP or UDP protocol. Therefore, Ping cannot test whether a specific port is in a listening state.
  • ICMP request has nothing to do with port number: The ICMP request message sent by Ping is a detection tool used to test network reachability. It just sends a message to the target host and requests a simple reply. It does not contain information related to the port number.
  • Port is a transport layer concept: Port number is a concept in transport layer protocols (such as TCP and UDP) used to distinguish different network applications or services. Ping is at the network layer and is more focused on testing the reachability between hosts, not the ports on the transport layer.

2. How to verify that the port number is available?

Common tools used to verify whether the port number is available include telnet, curl, nc (netcat), nmap, etc.

Verify the port using telnet:

 [root@localhost ~]# telnet 192.168.15.137 22 Trying 192.168.15.137... Connected to 192.168.15.137. Escape character is '^]'. SSH-2.0-OpenSSH_7.4 Connection closed by foreign host.

Use curl to verify the port (or call telnet to implement):

 [root@localhost ~]# curl -v telnet://192.168.15.137:22 * About to connect() to 192.168.15.137 port 22 (#0) * Trying 192.168.15.137... * Connected to 192.168.15.137 (192.168.15.137) port 22 (#0) SSH-2.0-OpenSSH_7.4 * Send failure: Broken pipe * Closing connection 0 curl: (55) Send failure: Broken pipe

Use curl to verify the port:

 [root@localhost ~]# curl 192.168.15.137:22 SSH-2.0-OpenSSH_7.4 Protocol mismatch. curl: (56) Recv failure: Connection reset by peer

Use nc to verify the port:

 [root@localhost ~]# nc -zv 192.168.15.137 22 Ncat: Version 7.50 ( https://nmap.org/ncat ) Ncat: Connected to 192.168.15.137:22. Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.
  • Verify the port using nmap:
 [root@localhost ~]# nmap -p 22 192.168.15.137 Starting Nmap 6.40 ( http://nmap.org ) at 2023-10-10 15:13 CST Nmap scan report for 192.168.15.137 Host is up (0.000057s latency). PORT STATE SERVICE 22/tcp open ssh Nmap done: 1 IP address (1 host up) scanned in 0.26 seconds

Summarize

Tools such as ping, telnet, curl, nc, nmap, etc. have different functions and uses. They are frequently used in work and can greatly improve our work efficiency. Have you learned them?

<<:  Emirates du and Huawei jointly launch the world's first "5G-A Smart Home" with 10G network support

>>:  Interviewer asked: What are the functions of the wait and notify methods in threads?

Recommend

The Difference Between a Network Hub and a Network Switch

What is a Network Hub? A hub in a computer networ...

Lightwave OFC 2025 Outlook: Quantum will take center stage

Beijing time, February 19 (Shui Yi) As the world&...

Is 5G really invincible? The sixth generation of Wi-Fi disagrees

With the official commercialization of the fifth ...

Why you don't understand HTTPS

I wrote an article about HTTPS the day before yes...

We will bear the consequences of irresponsible criticism of operators.

There was a problem with the telecom broadband at...

Protocol-Oriented Programming and Cocoa (Part 1)

[[403413]] This article is reprinted from the WeC...

Wi-Fi 7: What is it and when can you expect it to arrive?

[[380191]] Wi-Fi 7 is expected to have higher dat...

What does 5G high and low frequency networking mean?

[[346977]] This article is reprinted from the WeC...

Basic Principles for Campus Network Product Selection

I am Xia Jie, a lecturer at 51CTO Academy. On the...

Huawei Telnet and Stelnet login methods that make people dizzy

I am Zhao Jiexu, a lecturer at 51CTO Academy. On ...

Can we rely on HTTPS to keep us safe?

HTTPS is the guardian of web connections Most URL...

Deutsche Telekom expects 5G network to cover 50% of the German population by 2022

Telefénica/O2, the German telecom operator contro...