ubuntu16 在防火墙ufw出站规则中禁用echo-reply(type 0)、time-exceeded(type 11)、destination-unreachable(type 3)类型的ICMP包。
方法一、直接配置UFW出站规则
# 禁用"目的不可达"类型(Type 3)ICMP包的出站
sudo ufw deny out proto icmp to any icmp-type destination-unreachable
# 禁用"回显应答"类型(Type 0)ICMP包的出站
sudo ufw deny out proto icmp to any icmp-type echo-reply
# 禁用"超时"类型(Type 11)ICMP包的出站
sudo ufw deny out proto icmp to any icmp-type time-exceeded
方法二:编辑UFW配置文件
1.备份配置文件:在进行修改前,务必备份原始文件。
sudo cp /etc/ufw/before.rules /etc/ufw/before.rules.backup
2.编辑配置文件:使用文本编辑器 打开UFW的主要规则文件。
sudo vim /etc/ufw/before.rules
添加:
# 在*filter节后,在COMMIT行前的任意位置添加
-A ufw-before-output -p icmp --icmp-type destination-unreachable -j DROP
-A ufw-before-output -p icmp --icmp-type echo-reply -j DROP
-A ufw-before-output -p icmp --icmp-type time-exceeded -j DROP
2.重启ufw
sudo ufw disable
sudo ufw enable