专栏
天翼云开发者社区

ufw 开机状态还是处于inactive问题

2024-03-04 11:21:29 5阅读

解决ufw和netfilter同时存在ufw无法激活的问题

开机后,发现ufw一直处于inactive,查看 ufw状态, 本机也安装了docker,经过网上搜索和本地确认是
netfilter-persistent这服务导致的。

$ sudo service --status-all |grep netfilter
 [ + ]  netfilter-persistent
$ sudo ufw status

Status: inactive

确认ufw eanble 配置开启

# /etc/ufw/ufw.conf
#

# Set to yes to start on boot. If setting this remotely, be sure to add a rule
# to allow your remote connection before starting ufw. Eg: 'ufw allow 22/tcp'
ENABLED=yes

# Please use the 'ufw' command to set the loglevel. Eg: 'ufw logging medium'.
# See 'man ufw' for details.
LOGLEVEL=low

编辑ufw.service配置文件

/lib/systemd/system/ufw.service文件中增加 After=netfilter-persistent.service字段:

[Unit]
Description=Uncomplicated firewall
Documentation=man:ufw(8)
DefaultDependencies=no
Before=network.target
After=netfilter-persistent.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/lib/ufw/ufw-init start quiet
ExecStop=/lib/ufw/ufw-init stop

[Install]
WantedBy=multi-user.target

重启

$ sudo reboot
  • 0
  • 0
  • 0
0 评论
0/1000
评论(0) 发表评论
张****龙

张****龙

15 篇文章 0 粉丝
关注

ufw 开机状态还是处于inactive问题

2024-03-04 11:21:29 5阅读

解决ufw和netfilter同时存在ufw无法激活的问题

开机后,发现ufw一直处于inactive,查看 ufw状态, 本机也安装了docker,经过网上搜索和本地确认是
netfilter-persistent这服务导致的。

$ sudo service --status-all |grep netfilter
 [ + ]  netfilter-persistent
$ sudo ufw status

Status: inactive

确认ufw eanble 配置开启

# /etc/ufw/ufw.conf
#

# Set to yes to start on boot. If setting this remotely, be sure to add a rule
# to allow your remote connection before starting ufw. Eg: 'ufw allow 22/tcp'
ENABLED=yes

# Please use the 'ufw' command to set the loglevel. Eg: 'ufw logging medium'.
# See 'man ufw' for details.
LOGLEVEL=low

编辑ufw.service配置文件

/lib/systemd/system/ufw.service文件中增加 After=netfilter-persistent.service字段:

[Unit]
Description=Uncomplicated firewall
Documentation=man:ufw(8)
DefaultDependencies=no
Before=network.target
After=netfilter-persistent.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/lib/ufw/ufw-init start quiet
ExecStop=/lib/ufw/ufw-init stop

[Install]
WantedBy=multi-user.target

重启

$ sudo reboot
文章来自专栏

linux相关

15 篇文章 1 订阅
0 评论
0/1000
评论(0) 发表评论
  • 0
    点赞
  • 0
    收藏
  • 0
    评论