博客
关于我
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/

你可能感兴趣的文章
Node出错导致运行崩溃的解决方案
查看>>
node基础(二)_模块以及处理乱码问题
查看>>
node安装及配置之windows版
查看>>
Node提示:error code Z_BUF_ERROR,error error -5,error zlib:unexpected end of file
查看>>
Node读取并输出txt文件内容
查看>>
node防xss攻击插件
查看>>
NOIp2005 过河
查看>>
NOIp模拟赛二十九
查看>>
NOPI读取Excel
查看>>
NoSQL&MongoDB
查看>>
NoSQL介绍
查看>>
NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty()
查看>>
Now trying to drop the old temporary tablespace, the session hangs.
查看>>
np.arange()和np.linspace()绘制logistic回归图像时得到不同的结果?
查看>>
npm error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”。要解决此问题,1) 安装
查看>>
npm install digital envelope routines::unsupported解决方法
查看>>
npm install 卡着不动的解决方法
查看>>
npm install 报错 ERR_SOCKET_TIMEOUT 的解决方法
查看>>
npm install 报错 no such file or directory 的解决方法
查看>>
npm install报错,证书验证失败unable to get local issuer certificate
查看>>