# [Solved] Ufw cannot be enabled on boot

## reppk

Hello, everyone!

I installed ufw as my firewall, but it is always not enabled.

```
# systemctl status ufw.service 

● ufw.service - Uncomplicated Firewall

   Loaded: loaded (/usr/lib/systemd/system/ufw.service; enabled; vendor preset: 

   Active: active (exited) since Wed 2017-04-26 01:22:02 CST; 19min ago

 Main PID: 3739 (code=exited, status=0/SUCCESS)

   CGroup: /system.slice/ufw.service

Apr 26 01:22:02 woodman ufw-init[3739]: Skip starting firewall: ufw (not enabled

Apr 26 01:22:02 woodman systemd[1]: Started Uncomplicated Firewall.
```

I tried "ufw enable"commend, but it is disabled next time I boot the system.

What's the problem with my ufw setting?Last edited by reppk on Fri Apr 28, 2017 9:42 am; edited 1 time in total

----------

## reppk

I edited /etc/ufw/ufw.conf:

```
# /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
```

and restart ufw.service.  Then, my network goes down:

```
● ufw.service - Uncomplicated Firewall

   Loaded: loaded (/usr/lib/systemd/system/ufw.service; enabled; vendor preset: 

   Active: failed (Result: exit-code) since Wed 2017-04-26 02:24:14 CST; 46s ago

  Process: 3754 ExecStart=/usr/share/ufw/ufw-init start (code=exited, status=1/F

 Main PID: 3754 (code=exited, status=1/FAILURE)

Apr 26 02:24:14 woodman systemd[1]: ufw.service: Main process exited, code=exite

Apr 26 02:24:14 woodman ufw-init[3754]: iptables-restore: line 31 failed

Apr 26 02:24:14 woodman systemd[1]: Failed to start Uncomplicated Firewall.

Apr 26 02:24:14 woodman ufw-init[3754]: ip6tables-restore: line 27 failed

Apr 26 02:24:14 woodman systemd[1]: ufw.service: Unit entered failed state.

Apr 26 02:24:14 woodman ufw-init[3754]: Problem running '/etc/ufw/before.rules'

Apr 26 02:24:14 woodman ufw-init[3754]: Problem running '/etc/ufw/after.rules'

Apr 26 02:24:14 woodman ufw-init[3754]: Problem running '/etc/ufw/user.rules'

Apr 26 02:24:14 woodman ufw-init[3754]: Problem running '/etc/ufw/user6.rules'

Apr 26 02:24:14 woodman systemd[1]: ufw.service: Failed with result 'exit-code'.
```

What can I do?

----------

## szatox

Fix syntax* errors in your rules.

```
Apr 26 02:24:14 woodman ufw-init[3754]: iptables-restore: line 31 failed 

Apr 26 02:24:14 woodman ufw-init[3754]: ip6tables-restore: line 27 failed 
```

It was even kind enough to provide you the line number.

* may be a logical error rather than syntax, though these are less likely to be detected by machines

----------

## reppk

Thanks a lot.

It seems that ufw is not well supported in gentoo systemd.

I try to use iptables itself now.

----------

## Goverp

ufw problems often result from bits of iptables missing from your kernel configuration.  Run "/usr/share/ufw/check-requirements" to see.

----------

## niceflower

To enable ufw on startup add to default run level

In systemd i noticed that ufw is a bit troublesome

In openrc:

```

# ufw enable

# rc-update add ufw default

# ufw service start

```

----------

