通过防火墙设置禁止 Linux 中的 ping:安装 UFW、iptables-persistent、Firewalld;添加规则拒绝 ICMP 请求;保存或重启防火墙服务使规则生效。

如何在 Linux 中禁止 ping
在 Linux 系统中,您可以通过修改系统防火墙设置来禁止 ping 请求。以下是如何操作:
使用 UFW 防火墙
sudo apt-get install ufw。sudo ufw enable。sudo ufw deny proto icmp any any。使用 iptables
添加规则: 添加一条规则以丢弃来自所有来源的 ICMP(ping)请求:
<code>sudo iptables -A INPUT -p icmp -j DROP</code>
使用 IPTables-persistent
sudo apt-get install iptables-persistent。sudo netfilter-persistent save。使用 Firewalld
sudo yum install firewalld。sudo systemctl start firewalld。添加规则: 添加一条规则以拒绝来自所有来源的 ICMP(ping)请求:
<code>sudo firewall-cmd --permanent --add-rich-rule="rule family=ipv4 source address=any port port=33 destination address=any port port=0 protocol=icmp action=drop"</code>
sudo systemctl restart firewalld。完成上述步骤后,您的 Linux 系统将不再响应 ping 请求。
以上就是linux如何禁ping的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号