The ping is a term and command-line tool used to check remote system network connectivity. It is one of the most popular tools for network diagnostics. By default, the usage of the ping command does not require any port number and will work with just a target IP address or domain name. But you may ask what port number is used by the ping command.
The TCP and UDP protocols are very popular where they can provide multiple port numbers to provide different services over the network. The ping command can be related to these TCP and UDP protocols but it does not use TCP or UDP. This may be even asked you in an interview or certificate exam or class exam. The ping command uses the ICMP protocol. The ping is an old method and tool described in the RFC792 and this standard does not provide any port number for the ping.
Ping and ICMP Protocol
The ping tool uses the ICMP protocol which is different from the TCP and UDP protocol where it is tightly integrated with the IP protocol. The ICMP is a layer 3 protocol that is transmitted with the IP packets even the IP is also a layer 3 protocol too. The ICMP is created to support the IP protocol.
Ping Uses ICMP Type 8 and Type 0
Normally the ICMP protocol does not have any attribute or function like a port number. The ICMP protocol provides the Type, Code, Checksum, and Content parts. So there is no specific port number for the ping command. But the ICMP types Type 8 (Echo Message) and Type 0 (Echo Reply Message) are used for ping operation. The sender or pinger creates an ICMP packet with type 8 which requests the remote system to return an ICMP reply. The target if configured properly and accessible responds with the ICMP Type 0 response to this ping request.
Ping Packet Content
In order to investigate the ping ICMP packets, we will make a ping test to the popular Google DNS server IP address 220.127.116.11 and look to the ICMP packet details for the request and response. First start ping for the 18.104.22.168 with the following command.
$ ping 22.214.171.124
We can see below that the ICMP ping request from the IP addresses 192.168.142.133 to 126.96.36.199. If we look at the packet details of the ICMP protocol there is no port and port number information. The most distinctive information is the Type information which is “Type: 8 (Echo (ping) request)“
The response from the Google DNS server 188.8.131.52 is like below which is labeled as Echo ping reply. If we take a look at the response ICMP packet detailed there is no port or port number related information. But the “Type: 0 (Echo (ping) reply)” is the type of the ICMP reply packet.
Is Port 7 Used For Ping ICMP?
The short answer is no. In the old days of the computer, there were a lot of simple protocols to help users in different cases. The TCP and UDP protocol number 7 is assigned for a simple ping service port where both TCP and UDP protocol can be used to make ping tests. This service is called an echo test where after connecting to the TCP and UDP port 7 the transmitted data is returned as a response which creates an echo effect. But currently, most of the computers do not provide and serve this TCP and UDP port number 7 for this type of ping and connectivity check. As a general answer, the ICMP protocol does not use port number 7 which is a TCP and UDP service called echo that is absolute.
Alternative Way Ping TCP Ports
As stated previously the ping is a generic term that is used for different cases other than the ping command. There are different tools that can be used to ping TCP and UDP ports. These tools simply try to connect remote TCP ports and if the connection is established successfully this is called the ping is successful. You can take a look at the following post about pinging TCP ports with different tools like telnet, Nmap, Test-NetConenction, nc.