By default, Linux allows Ping responses. whether or not the system allows Ping is determined by two factors: A, kernel parameters, B, and firewall. Ping is allowed only when two factors are allowed at the same time, one of the two factors cannot be pinged if Ping is disabled. The specific configuration method is as follows: A. kernel parameter settings 1. allow PING settings &
By default, Linux allows Ping responses. whether or not the system allows Ping is determined by two factors: A, kernel parameters, B, and firewall. Ping is allowed only when two factors are allowed at the same time, one of the two factors cannot be pinged if Ping is disabled.
The specific configuration method is as follows:
A. kernel parameter settings
1. allow PING settings
A. The Command for temporarily allowing PING operation is: # echo 0>/proc/sys/net/ipv4/icmp_echo_ignore_all
B. The PING configuration method is permanently allowed.
/Etc/sysctl. confAdd a row
Net. ipv4.icmp _ echo_ignore_all = 1
If the line net. ipv4.icmp _ echo_ignore_all already exists, you can directly modify the value after the = sign (0 indicates allow, 1 indicates forbidden ).
After modification, executeSysctl-pMake the new configuration take effect.
2. disable Ping settings
A. The Command for temporarily disabling PING is: # echo 1>/proc/sys/net/ipv4/icmp_echo_ignore_all
B. The PING configuration method is permanently allowed.
/Etc/sysctl. confAdd a row
Net. ipv4.icmp _ echo_ignore_all = 0
If the line net. ipv4.icmp _ echo_ignore_all already exists, you can directly modify the value after =. (0 indicates allow, 1 indicates forbidden)
After modification, executeSysctl-pMake the new configuration take effect.
B. firewall settings (Note: The premise of this method is that the kernel configuration is the default value, that is, Ping is not prohibited)
Take Iptables firewall as an example. For more information about firewall operations, see the official firewall documentation.
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