Allow Ping for Single IP In Linux

Allow Ping for Single IP In Linux

To protect the server from attack or harm server admin may disable the Ping request from outer world but allow a single IP for himself to check sever connectivity. This tutorial will guide you to allow ping packets for one IP only

This whole process of allowing single IP is based on Iptables and there are basically two simple steps.
 
Step 1:
To allow the IP address for ping request use the following command. Replace x.x.x.x with the IP address you want to allow

iptables -A INPUT -s x.x.x.x -p ICMP --icmp-type 8 -j ACCEPT

This will allow ping request for source IP address.
 
Step 2:
To disable ping request for rest of the world.

iptables -A INPUT -p ICMP --icmp-type 8 -j DROP

 
This will drop all the ICMP request packets from any IP source except we allow in previous rule.
Please note that this rules will only applicables till sommeone flush all the iptables rules.