查看文章 |
Linux Iptables allow or block ICMP ping requestThe Internet Control Message Protocol (ICMP) has many messages that are identified by a "type" field. You need to use 0 and 8 ICMP code types. => Zero (0) is for echo-reply => Eight (8) is for echo-request. To enable ICMP ping incoming client request use following iptables rule (you need to add following rules to script). My default firewall policy is blocking everything. Task: Enable or allow ICMP ping incoming client requestRule to enable ICMP ping incoming client request ( assuming that default iptables policy is to drop all INPUT and OUTPUT packets) SERVER_IP="202.54.10.20" Task: Allow or enable outgoing ping requestTo enable ICMP ping outgoing request use following iptables rule: SERVER_IP="202.54.10.20" How do I disable outgoing ICMP request?Use the following rules: iptables -A OUTPUT -p icmp --icmp-type echo-request -j DROP OR iptables -A OUTPUT -p icmp --icmp-type 8 -j DROP ICMP echo-request type will be block by above rule. See ICMP TYPE NUMBERS (type fields). You can also get list of ICMP types, just type following command at shell prompt: |