How to Disable PING (ICMP Echo Replies) on Ubuntu Server 16.04.2

Introduction

PING is a commonly used network diagnostic tool that relies on ICMP (Internet Control Message Protocol) echo requests and replies to verify network connectivity between systems. While PING is useful for troubleshooting, some administrators choose to disable ICMP echo replies on production servers to reduce unnecessary network visibility and limit certain types of network reconnaissance.

Disabling ICMP responses can be beneficial in environments where security hardening is required or where administrators want to reduce the impact of excessive ICMP traffic.

Common Reasons to Disable ICMP Replies

  • Improve server security by reducing network exposure.
  • Prevent automated network discovery and scanning.
  • Reduce unnecessary ICMP traffic.
  • Mitigate network flooding attempts using commands such as ping -f.
  • Comply with specific organizational security policies.

Prerequisites

  • Ubuntu Server 16.04.2
  • Root or sudo access to the server

Disable PING (ICMP Echo Replies) Permanently

Step 1: Edit the sysctl Configuration File

Open the system kernel parameter configuration file:

vi /etc/sysctl.conf

Add the following line at the end of the file:

net.ipv4.icmp_echo_ignore_all = 1

Save the file and exit the editor.

Step 2: Apply the Changes

To immediately load and apply the new kernel parameter, run:

sysctl -p

You should see output similar to:

net.ipv4.icmp_echo_ignore_all = 1

This confirms that the configuration has been successfully applied.

Step 3: Verify the Configuration

You can verify the current setting by running:

sysctl net.ipv4.icmp_echo_ignore_all

Expected output:

net.ipv4.icmp_echo_ignore_all = 1

Testing

From another system, attempt to ping the server:

ping your-server-ip

The client will no longer receive ICMP echo replies and may display messages similar to:

Request timeout for icmp_seq 0

or

100% packet loss

depending on the operating system used for testing.


Re-Enable ICMP Replies

If you need to restore normal PING functionality, change the value back to:

net.ipv4.icmp_echo_ignore_all = 0

Then reload the configuration:

sysctl -p

Conclusion

Disabling ICMP echo replies is a simple yet effective security-hardening measure for Ubuntu servers. By modifying a single kernel parameter, administrators can prevent the server from responding to PING requests while keeping all other network services operational. Although this does not make a server completely invisible, it can reduce unnecessary exposure and help meet security requirements in production environments.


Frequently Asked Questions (FAQ)

1. Does disabling ICMP replies make my server completely invisible?

No. Disabling ICMP echo replies only prevents the server from responding to PING requests. Services such as SSH, HTTP, HTTPS, and other open ports can still be detected through network scans.

2. Will disabling PING affect website availability?

No. Your website, APIs, email services, and other applications will continue to function normally. Only ICMP echo requests (PING) will be ignored.

3. How can I check whether ICMP replies are disabled?

Run the following command:

sysctl net.ipv4.icmp_echo_ignore_all

If the output is:

net.ipv4.icmp_echo_ignore_all = 1

ICMP echo replies are disabled.


  1. How to disable PING or ICMP replies from a Ubuntu Server 16.04.2 Temporarily
  2. SSH setup in a newly installed Ubuntu 16.04.2 server
  3. Add webmail alias in VestaCP panel – ubuntu 16.04

admin

Writes about Web & Architecture at Pheonix Solutions.

Leave a Reply

Scroll to Top