Operations 3 min read

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.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Permanently Disable Ping Replies on Linux Systems

Permanent Ping Disable

First verify whether the system currently allows ping replies:

cat /proc/sys/net/ipv4/icmp_echo_ignore_all
0

In 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 = 1

Test 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 191ms

Temporary Ping Disable (effective until reboot)

Check the current setting (normally 0):

cat /proc/sys/net/ipv4/icmp_echo_ignore_all
0

Set the value temporarily using sysctl -w:

sysctl -w net.ipv4.icmp_echo_ignore_all=1
net.ipv4.icmp_echo_ignore_all = 1

Confirm the change took effect:

cat /proc/sys/net/ipv4/icmp_echo_ignore_all
1

Another Temporary Method

Write directly to the proc file to disable ping until the next reboot:

echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

pingLinux
Liangxu Linux
Written by

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.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.