How to Enable & Disable Ping (ICMP Echo Requests) from IPTables on Linux Cloud Servers

2020-05-18 By Aaron 7945 Views linux ping networking
1 reviews

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.


pingdiagram


This guide outlines the basic steps to enable and disable Ping from IPTables on the Linux server.


Enabling Ping:


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

    pinglinux1

  2. Once the ping enabled, the server should now respond to ping requests as shown in the below image.

    pinglinux2

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

    pinglinux3


Disabling Ping:


  1. Verify the installation and check the version of the iptables by using the below command.

    # iptables --version
    

    pinglinux4

  2. 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
    
  3. List the rules added in iptables using the below command.

    # iptables -L
    

    pinglinux5

  4. Once the ping disabled, the server should now respond to ping requests as shown in the below image.

    pinglinux6


Related Tutorials

What do you think about this article?

Rate this article