In Linux and CentOS, how does one set to prohibit others from pinging our own servers? below we will introduce some common methods: 1. Use a root account to access the system, then edit the file icmp_echo_ignore_allvi/proc/sys/net/ipv4/icmp_echo_ignore_all0 to allow ping1 to prohibit ping and run the following command: [root @ 00
In Linux and CentOS, how does one set to prohibit others from pinging our own servers? below we will introduce some common methods.
1. enter the system as the root account and edit the file icmp_echo_ignore_all.
Vi/proc/sys/net/ipv4/icmp_echo_ignore_all
0 indicates that ping is allowed.
1 indicates ping prohibited.
You can directly run the following command
[Root @ 00isp ~] # Echo 1>/proc/sys/net/ipv4/icmp_echo_ignore_all
[Root @ 00isp ~] # Echo 0>/proc/sys/net/ipv4/icmp_echo_ignore_all
The effect of the above two commands takes effect in real time. you can use another machine to ping the command to test whether the command takes effect. The preceding method only temporarily disables ping and then becomes invalid after restart. if you do not want to ping after restart, you can do the following:
Add a row to/etc/rc. d/rc. local.
Echo 1>/proc/sys/net/ipv4/icmp_echo_ignore_all
In addition, you can add a line in the configuration file/etc/sysctl. conf.
Net. ipv4.icmp _ echo_ignore_all = 1
2. disable PING using IPTables
Echo "1">/proc/sys/net/ipv4/icmp_echo_ignore_all
This is because someone else cannot ping you or ping someone else. In fact, using iptable is the easiest
Iptables-a input-p icmp -- icmp-type 8-s 0/0-j DROP
Iptables-a input-p icmp -- icmp-type 0-s 0/0-j ACCEPT
Iptables-a output-p icmp -- icmp-type 0-s 192.168.29.1-j DROP
Iptables-a output-p icmp -- icmp-type 8-s 192.168.29.1-j ACCEPT