17

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?

New contributor
joseph is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
5
  • there's a free windows utility called paping which can test a TCP port instead of a normal ICMP packet. In that case you specify the port number. It is similar to using telnet or putty to connect to a specific port with a short timeout. – LPChip yesterday
  • @LPChip I assume you mean PsPing (typo?) – user541686 23 hours ago
  • 2
    No need to download anything. Powershell has a Test-NetConnection cmdlet that’ll test a specific port. docs.microsoft.com/en-us/powershell/module/nettcpip/… – Greg W 19 hours ago
  • @user541686 no, paping: code.google.com/archive/p/paping/downloads. PsPing looks interesting though. :) More capable it seems. Have to try that out. – LPChip 15 hours ago
  • I don't want to answer about Windows, if the question is about Linux, but it looks like from NetLimiter that Windows will listen on port 139 for ping requests with System process 4. They show up there every time and that process number is constant, even though ping uses ICMP as noted below. I'm not entirely sure what the reason for that is, so I can't really give a properly formed answer, because I'm not entirely sure that use of that port is operating system independent. – user56983 40 mins ago
35

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:

cat /proc/sys/net/ipv4/icmp_echo_ignore_all
  • 0 means Ping is enabled. (The system will respond to pings)
  • 1 means Ping is disabled (The system will not respond to pings)
8
  • 3
    Concur - there are other things named "ping" like tcpping and arping that work on different protocols, but they're not the common ping. – Criggie 17 hours ago
  • But isn't ping a service running on a system responding to the ping request. And won't any service on the internet will have a port number? – joseph 8 hours ago
  • 2
    @joseph TCP and UDP protocol services will have ports. ICMP doesn't have that concept. If you used ICMP protocol to send a message, you don't specify a port, just that protocol. – Josh Zhang 8 hours ago
  • 4
    @joseph: nope! Port numbers are a thing for tcp and udp, but icmp is a separate protocol at the same level; it's distinguished as protocol 1 in the protocol field of the IP packet (tcp and udp are 6 and 17 respectively). As to whether it's a "service", well, anything can be modelled as a service, but it's certainly not implemented as a daemon listening on a tcp or udp port. In most cases I believe it's answered within the OS kernel, except for OSs in which TCP is modularized outside the kernel. – CCTO 8 hours ago
  • 1
    @joseph We may be talkjing about "port" without relation to TCP or UDP, but then it may be in the context of marine traffic or wine (not the Windows emulator). – Hagen von Eitzen 4 hours ago
24

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.

Your Answer

joseph is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.