Home >Operation and Maintenance >Linux Operation and Maintenance >Example code sharing of how to disable ping in Linux
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!