Home  >  Article  >  Operation and Maintenance  >  Example code sharing of how to disable ping in Linux

Example code sharing of how to disable ping in Linux

黄舟
黄舟Original
2017-06-01 11:00:241772browse

This article mainly introduces the relevant information on the implementation examples of linux prohibiting ping. Friends who need it can refer to the

Linux implementation examples of prohibiting ping

1. The command to temporarily disable PING operation is : #echo 1>/proc/sys/net/ipv4/icmp_echo_ignore_all

2. Permanently prohibit PING configuration method

  /etc/sysctl.conf 中增加一行

   net.ipv4.icmp_echo_ignore_all=1

   执行sysctl -p生效

Firewall method:

1. Allow PING settings

     iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT

    iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT

or you can temporarily stop the firewall operation.

  service iptables stop

2. Disable PING settings

  iptables -A INPUT -p icmp --icmp-type 8 -s 0/0 -j DROP

The above is the detailed content of Example code sharing of how to disable ping in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn