CentOS 7 - 禁止 ping 响应

CentOS 7 - 禁止 ping 响应

环境信息

操作系统:

# rpm -q centos-release 
centos-release-7-6.1810.2.el7.centos.x86_64

禁止 ping 响应

编辑 /etc/sysctl.conf 文件,加入 net.ipv4.icmp_echo_ignore_all=1(0 允许,1 禁止):

# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).

net.ipv4.icmp_echo_ignore_all=1

修改完成之后,执行 sysctl -p 命令从文件读取值,使配置生效。

测试

在另一台主机中使用 ping 命令测试配置是否生效:

# ping -c 10 192.168.88.171 // -c 10 表示在 10 次回答之后停止
PING 192.168.88.171 (192.168.88.171) 56(84) bytes of data.

--- 192.168.88.171 ping statistics ---
10 packets transmitted, 0 received, 100% packet loss, time 9196ms
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值