Ping prohibited from centos

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.