Home  >  Article  >  Operation and Maintenance  >  What should I do if CentOS cannot be pinged?

What should I do if CentOS cannot be pinged?

angryTom
angryTomOriginal
2020-03-17 18:10:114403browse

What should I do if CentOS cannot be pinged?

What to do if CentOS cannot be pinged

CentOS cannot be pinged because pinging is disabled. The solution is to set the server to allow pinging.

Linux allows Ping response by default. Whether the system allows Ping is determined by two factors: A. Kernel parameters, B. Firewall. Ping needs to be allowed by allowing both factors at the same time. Either of the two factors must be allowed. If ping is disabled, ping will become impossible.

Recommended learning: Linux video tutorial

The specific configuration method is as follows:

1. Modify the kernel parameters

1. The command to temporarily allow PING operation is:

#echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_all

2. Permanently allow PING configuration method.

Add a line to/etc/sysctl.conf

net.ipv4.icmp_echo_ignore_all=0

If there is already a line of net.ipv4.icmp_echo_ignore_all, just modify the value after the = sign (0 means allowed, 1 means prohibited).

After the modification is completed, execute sysctl -p to make the new configuration take effect.

2. Firewall settings (Note: The premise of the method here is that the kernel configuration is the default value, that is, Ping is not prohibited)

Here Iptables Take the firewall as an example. For other firewall operation methods, please refer to the official documentation of the firewall.

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 also temporarily stop the firewall operation.

service iptables stop

This article comes from the PHP Chinese website, CentOS usage tutorial column, please pay attention to this column for more related tutorials!

The above is the detailed content of What should I do if CentOS cannot be pinged?. 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