How to Deny ICMP Ping Request on CentOS 6.2

Ping is a computer network administration utility used to test the reachability of a host on an Internet Protocol (IP) network. Ping operates by sending Internet Control Message Protocol (ICMP) echo request packets to the target host and waiting for an ICMP response. ICMP protocol is used by ping command to check the connectivity between two computers. By defaults all Linux CentOS servers will response on ICMP request. Hacker can misuse this service. They can generate countless ping requests to your Linux server. This is what called DOS denial of services.

See also  How to Monitor Bandwidth Usage with vnStat on Linux CentOS 6.2 Server

Before changes, i can ping 192.168.1.44 as below :

D:\>ping 192.168.1.44

Pinging 192.168.1.44 with 32 bytes of data:

Reply from 192.168.1.44: bytes=32 time=1ms TTL=64
Reply from 192.168.1.44: bytes=32 time=1ms TTL=64
Reply from 192.168.1.44: bytes=32 time=2ms TTL=64
Reply from 192.168.1.44: bytes=32 time=1ms TTL=64

Ping statistics for 192.168.1.44:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 1ms, Maximum = 2ms, Average = 1ms

In this post, i will show on how to block ICMP ping request from others.

Method 1 :
To disable ICMP ping immediately, type the following command :

[root@centos62 ~]# echo  1 > /proc/sys/net/ipv4/icmp_echo_ignore_all

Method 2 :
To disable ICMP ping after reboot, modify the /etc/sysctl.conf as below. This will permanently disable the ICMP ping echo. Kindly append at the end line of the file :

[root@centos62 ~]# vi /etc/sysctl.conf
..
..
..
# Controls the maximum size of a message, in bytes
kernel.msgmnb = 65536

# Controls the default maxmimum size of a mesage queue
kernel.msgmax = 65536

# Controls the maximum shared segment size, in bytes
kernel.shmmax = 4294967295

# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 268435456

net.ipv4.icmp_echo_ignore_all = 1

Change will take effect after reboot :

[root@centos62 ~]# reboot

Try to ping again. The server will not reply now :

D:\>ping 192.168.1.44

Pinging 192.168.1.44 with 32 bytes of data:

Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 192.168.1.44:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

How to Reset the Directory Manager Password on RHEL 7 / CentOS 7
How to Reset the Directory Manager Password on RHEL 7 / CentOS 7

It is best practice to remember passwords, but because too many passwords, sometimes we forget. We are not encouraged to write the password on any paper or share the password...

How to Find Big Files Size on Linux RHEL/CentOS
How to Find Big Files Size on Linux RHEL/CentOS

As the linux administrator, sometimes we have to identify which files are most take much space in the linux server resulting in low free space. Low disk space can also...

Why Linux users should worry about malware and what they can do about it
Why Linux users should worry about malware and what they can do about it

Don’t drop your guard just because you’re running Linux. Preventing the spread of malware and/or dealing with the consequences of infection are a fact of life when using computers. If...

How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7
How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7

This short howto will explain the steps to reset a lost root password or to reset a forgotten root password on Linux RHEL 7 or CentOS 7. Basically, we will...

How to Update CentOS or Upgrade CentOS to the Latest Version
How to Update CentOS or Upgrade CentOS to the Latest Version

Recently, the latest version of CentOS 7.3 was released. All users of CentOS 7.0, 7.1 and 7.2 can upgrade their system to the most recent. This quick guide will explain...

How to Change your WordPress Username, Nickname and Display Name in MySQL
How to Change your WordPress Username, Nickname and Display Name in MySQL

After you create an account log in WordPress, you may want to change your WordPress username, as appropriate or due to security reason. However, you can not do this from...

How to Enable SSH Root Login on Ubuntu 16.04
How to Enable SSH Root Login on Ubuntu 16.04

As what we wrote in the previous article on how to allow SSH root on Ubuntu 14.04, after installing a fresh new copy of Ubuntu 16.04 LTS, we find that...

How to Change UUID of Linux Partition on CentOS 7
How to Change UUID of Linux Partition on CentOS 7

UUID (Universally Unique IDentifier) should be unique and it is used to identify storage devices on a linux system. If you cloned a virtual machine from vCenter, the metadata containing...

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *