PING (Packet Internet Groper) command is used to check the network connectivity between a source and destination and it use ICMP(Internet Control Message Protocol) to send echo request messages to the destination and waiting for a response.
This guide outlines the basic steps to enable and disable Ping from IPTables on the Linux server.
Run the below command to enable ping on the server. It removes the rules if any blocking ping and will make network troubleshooting easier.
# iptables -D INPUT -p icmp --icmp-type echo-request -j REJECT
D : This command switch is used to delete the rule.
Once the ping enabled, the server should now respond to ping requests as shown in the below image.
If necessary, you may remove the all custom rules from iptables by using the below command.
# iptables -F
Once you have removed the rules, please use the below command to check whether any more rules are present in iptables.
# iptables -L
Verify the installation and check the version of the iptables by using the below command.
# iptables --version
The iptables is the Linux command line firewall which allows us to manage incoming and outgoing traffic based on set of rules. The following rules used to disable ping to and from the server normally.
# iptables -A INPUT -p icmp --icmp-type echo-request -j REJECT
A : This command switch is used to add the rule.
Or else, use the below rules in order to disable ping without printing an error message.
# iptables -A INPUT -p icmp --icmp-type echo-request -j DROP
# iptables -A OUTPUT -p icmp --icmp-type echo-reply -j DROP
List the rules added in iptables using the below command.
# iptables -L
Once the ping disabled, the server should now respond to ping requests as shown in the below image.