How to Permanently Disable Ping Replies on Linux Systems
This guide explains how to check the current ping response setting on a Linux server, permanently disable it by editing sysctl.conf, apply the change with sysctl, and verify the effect, as well as offering temporary alternatives that last only until reboot.
Permanent Ping Disable
First verify whether the system currently allows ping replies:
cat /proc/sys/net/ipv4/icmp_echo_ignore_all
0In this output, 0 means ping is allowed, while 1 would block it.
Edit the /etc/sysctl.conf file and add the following line to block ping permanently: net.ipv4.icmp_echo_ignore_all = 1 Apply the new configuration without rebooting:
sysctl -p
... net.ipv4.icmp_echo_ignore_all = 1Test the result from another machine; the ping should fail with 100% packet loss:
ping 8.40.7.17
PING 8.40.7.17 (8.40.7.17) 56(84) bytes of data.
^C
--- 8.40.7.17 ping statistics ---
8 packets transmitted, 0 received, 100% packet loss, time 191msTemporary Ping Disable (effective until reboot)
Check the current setting (normally 0):
cat /proc/sys/net/ipv4/icmp_echo_ignore_all
0Set the value temporarily using sysctl -w:
sysctl -w net.ipv4.icmp_echo_ignore_all=1
net.ipv4.icmp_echo_ignore_all = 1Confirm the change took effect:
cat /proc/sys/net/ipv4/icmp_echo_ignore_all
1Another Temporary Method
Write directly to the proc file to disable ping until the next reboot:
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_allSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
