Is there any particular port number that the
ping command works on by default?
Also on a Linux system, is there a way to figure out by yourself which port numbers it runs on and configure a different port number for it?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
Ping uses the ICMP protocol which doesn't have ports like the TCP and UDP protocols.
If you need to see if Ping is disabled on a Linux system, you can check:
TCP/IP uses a four-layer network stack. The Link layer deals with the physical media and how to get bytes across, the Internet layer deals with IP addresses and how to route data from one node to another, the Transport layer deals with TCP and UDP sessions, and the Application layer is what user programs use to interact with the network normally.
Pings are implemented as part of ICMP, the Internet Control Message Protocol, which deals with things like errors, congestion, and the like. ICMP is implemented in the Internet layer, and is therefore blissfully ignorant of things like encryption, ports, sessions, and other things provided by the upstream layers, and is also unaware of how the bytes are physically getting from point A to point B (which is the main point of the Link layer).
All of this means that pings are inherently without a port. They don't operate on any port number, as those are implemented in a different level. When you request a ping, this operation effectively bypasses the Application and Transport Layers, and directly asks the Internet layer to diagnose a connection (namely, to see how long it takes to get a response). This is often directly implemented in a network driver, and doesn't require any special user application to request or respond to a ping.
You can turn pings responses on and off, but you can't configure something that literally has no concept in the layer you're asking about. For any given Operating System, you simply need to check your online manual for how to enable or disable ping responses. The other answer goes into detail about enabling/disabling it on Linux, while this answer was meant to address why there are no ports that can be configured for pings.
What port does 'ping' work on?
Ping actually is NOT a service in the traditional sense. There is no ping daemon server.
Ping (formally, ICMP Echo) is provided by the IP driver in the kernel, perhaps even by hardware itself in some architectures with hardware offloading. Also as others have mentioned, it uses ICMP. The world isn't split between either udp or tcp.
Other Layer4 protocols exist with varying degrees of commonality, like ICMP, IGMP, PPTP, part of IPSec.
There is a spinoff of ping called tcping which accomplishes the same thing as ping more or less, using a tcp port of your choosing. In its case, there still isn't a "ping server". The "server" is whatever server software you happen to point it at.