全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

IP归属甄别会员请立即修改密码
查看: 427|回复: 3
打印 上一主题 下一主题

服务器防护之如何禁用ICMP

[复制链接]
跳转到指定楼层
1#
发表于 2022-2-15 13:14:46 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
本帖最后由 xiaomifan 于 2022-3-6 15:01 编辑

Instructions
Update UFW rules
In order to deny any incoming ICMP ping requests we need to modify /etc/ufw/before.rules UFW’s configuration file. First, make a backup copy:

$ sudo cp /etc/ufw/before.rules /etc/ufw/before.rules_backup
Next, open the file with root privileges using your favorite text editor and change:

FROM:

# ok icmp codes for INPUT
-A ufw-before-input -p icmp --icmp-type destination-unreachable -j ACCEPT
-A ufw-before-input -p icmp --icmp-type source-quench -j ACCEPT
-A ufw-before-input -p icmp --icmp-type time-exceeded -j ACCEPT
-A ufw-before-input -p icmp --icmp-type parameter-problem -j ACCEPT
-A ufw-before-input -p icmp --icmp-type echo-request -j ACCEPT
TO:

# ok icmp codes for INPUT
-A ufw-before-input -p icmp --icmp-type destination-unreachable -j DROP
-A ufw-before-input -p icmp --icmp-type source-quench -j DROP
-A ufw-before-input -p icmp --icmp-type time-exceeded -j DROP
-A ufw-before-input -p icmp --icmp-type parameter-problem -j DROP
-A ufw-before-input -p icmp --icmp-type echo-request -j DROP

Alternatively, use the below sed command to perform the change:

$ sudo sed -i '/ufw-before-input.*icmp/s/ACCEPT/DROP/g' /etc/ufw/before.rules
Enable Firewall
Enable UFW firewall using the following linux command:

$ sudo ufw enable
Alternatively, if your firewall is already enabled you can reload it with:

$ sudo ufw reload
4#
发表于 2022-2-15 14:37:39 | 只看该作者
okay,I zhi dao le.
3#
发表于 2022-2-15 14:32:10 | 只看该作者

不方便,有没有被墙都不知道
2#
发表于 2022-2-15 13:17:10 来自手机 | 只看该作者
不方便,自己都看不到
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-11-10 05:42 , Processed in 0.058723 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表