请先安装ufw:
curl -sS -O https://raw.githubusercontent.com/woniu336/open_shell/main/block_censys_ips.sh && chmod +x block_censys_ips.sh && ./block_censys_ips.sh
一键脚本
curl -sS -O https://raw.githubusercontent.com/woniu336/open_shell/main/nftables-manager.sh && chmod +x nftables-manager.sh && ./nftables-manager.sh
虽然nftables好用,但是容易和ufw、某些docker应用不兼容,会出问题,所以,最好是专门用于转发用。
注意事项
很重要!!!
- 会自动禁用ufw防火墙,
- 不要在已有生产环境测试(docker)
- 不要开启ufw,
- 仅适用于新机
万一你头铁,可能导致docker应用故障,使用以下方式恢复
# 安装 iptables-nft 包 sudo apt install -y iptables-nft # 切换到 iptables-legacy 模式 sudo update-alternatives --set iptables /usr/sbin/iptables-legacy sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy sudo update-alternatives --set arptables /usr/sbin/arptables-legacy sudo update-alternatives --set ebtables /usr/sbin/ebtables-legacy # 重启 Docker 服务 sudo systemctl restart docker
本文作者为萝莉工坊,转载请注明。