What port does ping use?
Short answer
Trick question — ping uses no port. It runs on ICMP, which is a Layer-3 protocol that sits directly on top of IP. Ports only exist in Layer-4 protocols like TCP and UDP, so ICMP (and therefore ping) has none. ICMP uses type and code fields instead, e.g. Echo Request type 8 and Echo Reply type 0.
This question is a classic filter. The interviewer is not testing whether you have memorised a number — they are checking whether you understand where ports come from in the protocol stack.
Why the premise is wrong
Ports are an addressing mechanism that belongs to Layer 4 of the OSI model. TCP and UDP use a 16-bit source port and a 16-bit destination port so that one host can multiplex many simultaneous conversations. Ping does not use TCP or UDP. It uses ICMP, which sits directly on top of IP at Layer 3. ICMP has no concept of a port, so asking which port ping uses is like asking which floor of a single-storey house is the top one.
What ICMP actually uses
Instead of ports, ICMP messages carry a type and a code. Ping sends an Echo Request (type 8, code 0) and expects an Echo Reply (type 0, code 0). The distractors deliberately confuse the type number with a port, or invent an echo "service port" — UDP port 7 is the unrelated legacy echo service, not ping.
The firewall consequence
Because there is no port, you cannot "block ping" with a port rule. You filter on the protocol number (ICMP is IP protocol 1) and optionally on ICMP type.
What interviewers look for
A confident "it has no port, here's why" plus the Layer-3-versus-Layer-4 reasoning. Candidates who blurt out a number have revealed they pattern-match instead of understanding the stack.
Likely follow-ups
- Which OSI layer does ICMP operate at, and what does it sit on top of?
- How would you 'block ping' on a firewall if there is no port to filter?
- What is the difference between an ICMP type and a TCP/UDP port?