更新UFW规则
为了拒绝任何传入的ICMP ping请求,我们需要修改/etc/ufw/before.rules
ufw的配置文件。
首先,备份一下配置文件:
$ sudo cp /etc/ufw/before.rules /etc/ufw/before.rules_backup
修改配置文件,
将
# 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
改成:
# 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
或者,使用以下sed
命令执行修改:
$ sudo sed -i '/ufw-before-input.*icmp/s/ACCEPT/DROP/g' /etc/ufw/before.rules
启用防火墙
使用以下Linux命令启用UFW防火墙:
$ sudo ufw enable
或者,如果防火墙已启用,则可以将其重新加载:
$ sudo ufw reload
日期:2020-07-07 20:55:17 来源:oir作者:oir