Ping接收ICMP回显应答时是否验证校验和?Fedora 27环境咨询
Great question—even though the ping man page doesn’t spell this out explicitly, the answer is yes: the ping utility included with Fedora 27 (part of the iputils package) absolutely validates ICMP echo reply checksums by default. Here’s the breakdown:
Why This Makes Sense
First, RFC 792 mandates checksum validation for all ICMP messages as a core part of ensuring packet integrity during transmission. Any compliant ICMP implementation (including ping) has to adhere to this requirement—skipping it would break the protocol’s basic design.
The iputils Ping Implementation
Fedora 27 uses the iputils version of ping. If you dig into its source code, you’ll find explicit logic that calculates the expected checksum for incoming echo reply packets and compares it to the checksum field in the received packet. If the values don’t match, the packet is silently discarded—you won’t see it show up as a successful reply in your ping output.
How to Test This Yourself
If you want to confirm this behavior hands-on:
- Use a packet crafting tool to create an ICMP echo reply with an intentionally invalid checksum.
- Send this modified packet to your Fedora 27 system while running
pingagainst the source IP you used for the crafted packet. - You’ll notice
pingnever acknowledges this invalid packet—it won’t count it as a reply, and your output will show no corresponding "bytes from" line.
Can You Turn Off Checksum Validation?
There’s no documented command-line flag in Fedora 27’s ping to disable this check. That’s by design—skipping checksum validation would violate ICMP compliance and leave you open to corrupted or malicious packets.
内容的提问来源于stack exchange,提问作者FGreg

