![尝试在 Ubuntu 上启用 ufw 日志时出错](https://linux22.com/image/734698/%E5%B0%9D%E8%AF%95%E5%9C%A8%20Ubuntu%20%E4%B8%8A%E5%90%AF%E7%94%A8%20ufw%20%E6%97%A5%E5%BF%97%E6%97%B6%E5%87%BA%E9%94%99.png)
我正在尝试为 ufw 启用日志。
当我这样做时sudo ufw status
我得到
Status: active
To Action From
-- ------ ----
53535 ALLOW Anywhere
9090 ALLOW Anywhere
1883 ALLOW Anywhere
22 ALLOW Anywhere
53535 (v6) ALLOW Anywhere (v6)
9090 (v6) ALLOW Anywhere (v6)
1883 (v6) ALLOW Anywhere (v6)
22 (v6) ALLOW Anywhere (v6)
哪个可以
然后我尝试启用日志:
[root@artik log]# ufw logs on 错误:无法更新正在运行的防火墙
因此我尝试禁用防火墙,启用日志记录并重新启动 ufw
[root@artik log]# ufw disable
Firewall stopped and disabled on system startup
[root@artik log]# ufw logging on
Logging enabled
[root@artik log]# ufw enable
ERROR: problem running ufw-init
iptables-restore: line 43 failed
ip6tables-restore: line 138 failed
ip6tables-restore: line 43 failed
Problem running '/etc/ufw/user.rules'
Problem running '/etc/ufw/before6.rules'
Problem running '/etc/ufw/user6.rules'
为什么会发生这种情况?我应该怎么做才能解决它?
答案1
以下是我修复它的方法
禁用 IPV6/etc/default/ufw
改成IPV6=yes
IPV6=no
日志显示错误,所以我禁用了它
ufw logging off
然后我配置了防火墙
ufw default allow outgoing
ufw default deny incoming
ufw allow out on tun0
ufw allow in on tun0
ufw enable
希望它能帮助其他人!