Configure Linux disable ping and allow ping

Source: Internet
Author: User

Production server:

Os:centos Release 6.8 (Final)

Task: Configure ping with kernel parameters

First, the temporary effective configuration method:

Do not allow local ping

[[email protected] ~]$ Ping 117.40.*.*

PING 117.40.*.* (117.40.*.*) bytes of data.

[[email protected] ~]$ ping 127.0.0.1

PING 127.0.0.1 (127.0.0.1) bytes of data.

Client ping to this server is not allowed

[[email protected] ~]# Ping 117.40.*.*

PING 117.40.*.* (117.40.*.*) bytes of data.

The operation is configured as follows:

[Email protected] ~]$ Cat/proc/sys/net/ipv4/icmp_echo_ignore_all

1

A local ping or client ping to the server is changed to 0 for 1

[Email protected] sky]# echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_all

[Email protected] sky]# Cat/proc/sys/net/ipv4/icmp_echo_ignore_all

0

Test results:

[[email protected] sky]# ping 127.0.0.1

PING 127.0.0.1 (127.0.0.1) bytes of data.

Bytes from 127.0.0.1:icmp_seq=1 ttl=64 time=0.057 ms

[[email protected] ~]# Ping 117.40.*.* # Client Testing Ping Server

PING 117.40.*.* (117.40.*.*) bytes of data.

Bytes from 117.40.*.*: icmp_seq=1 ttl=64 time=0.438 ms

Second, the permanent Way of entry into force:

[Email protected] sky]# vi/etc/sysctl.conf

.........

net.ipv4.icmp_echo_ignore_all = 0 # allow Ping, set 1 prohibit ping

[email protected] sky]# sysctl–p # make the new configuration effective

This article is from the "sky9890" blog, make sure to keep this source http://sky9896.blog.51cto.com/2330653/1886609

Configure Linux disable ping and allow ping

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.