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