博客
关于我
Linux服务器安全防护之禁止ping
阅读量:114 次
发布时间:2019-02-26

本文共 1049 字,大约阅读时间需要 3 分钟。

Linux服务器安全防护:禁止ping CentOS服务器IP地址

在某些网络环境下,防止未经授权的ICMP包请求到服务器是非常重要的操作。以下是两条简单命令,用于实现这一目标。

首先,编辑sysctl配置文件

运行以下命令,将ICMP包忽略所有请求的设置添加到sysctl配置文件中:

echo 'net.ipv4.icmp_echo_ignore_all = 1' > /etc/sysctl.conf

这一步是关键,因为它直接关联到我们想要实现的目标。net.ipv4.icmp_echo_ignore_all = 1 这个参数设置会让Linux服务器拒绝所有ICMP包的请求,从而防止未经授权的“ping”请求到达服务器。

其次,应用sysctl配置

为了让sysctl配置生效,需要重新加载配置文件:

sysctl -p

运行上述命令后,您应该会看到sysctl重新加载配置,并显示以下信息:

net.ipv6.conf.all.disable_ipv6 = 0net.ipv6.conf.default.disable_ipv6 = 0net.ipv6.conf.lo.disable_ipv6 = 0kernel.printk = 5net.ipv4.icmp_echo_ignore_all = 1

注意:net.ipv6.conf.*.disable_ipv6 = 0 这些参数保留了默认的IPv6设置,不会影响我们的主要目标。

验证配置是否成功

为了确认配置是否生效,可以重新查看/etc/sysctl.conf文件:

cat /etc/sysctl.conf

输出结果应包含以下内容:

net.ipv6.conf.all.disable_ipv6=0net.ipv6.conf.default.disable_ipv6=0net.ipv6.conf.lo.disable_ipv6=0kernel.printk = 5net.ipv4.icmp_echo_ignore_all = 1

如果ICMP包仍然可以到达服务器,请确保sysctl服务正在运行:

systemctl status sysctl

如果sysctl服务未启用,可以启用并重启它:

systemctl enable sysctlsystemctl restart sysctl

通过以上步骤,您可以轻松实现禁止ping请求到服务器的目标。这一设置尤其适用于需要保护服务器免受未经授权访问或DDoS攻击的场景。

转载地址:http://qsry.baihongyu.com/

你可能感兴趣的文章
PIL.Image、cv2的img、bytes相互转换
查看>>
PIL.Image进行图像融合显示(Image.blend)
查看>>
Pillow lacks the JPEG 2000 plugin
查看>>
SpringBoot之ElasticsearchRestTemplate常用示例
查看>>
ping 全网段CMD命令
查看>>
ping 命令的七种用法,看完瞬间成大神
查看>>
Pinia:$patch的使用场景
查看>>
Pinia:$subscribe()的使用场景
查看>>
Pinpoint对Kubernetes关键业务模块进行全链路监控
查看>>
Pinterest 大规模缓存集群的架构剖析
查看>>
pintos project (2) Project 1 Thread -Mission 1 Code
查看>>
PinYin4j库的使用
查看>>
PIP
查看>>
pip install goose-extractor // SyntaxError: Missing parentheses in call to 'print'
查看>>
pip install mysqlclient报错
查看>>
pip install 出现报asciii码错误的解决
查看>>
pip throws TypeError: parse() got an unexpected keyword argument ‘transport_encoding‘ 在尝试安装新软件包时
查看>>
pip 下载慢
查看>>
pip 升级报错AttributeError: ‘NoneType’ object has no attribute ‘bytes’
查看>>
pip 安装opencv-python卡死
查看>>