Comment 4 for bug 1726856

Revision history for this message
Matt Caswell (matt-openssl) wrote :

This issue still seems to be a problem in 18.04.

If found a solution:
https://askubuntu.com/questions/1040539/how-do-i-get-ufw-to-start-on-boot/1040584

I edited /lib/systemd/system/ufw.service as follows:

$ diff -u ufw.service.orig ufw.service
--- ufw.service.orig 2018-05-26 13:45:48.696356561 +0100
+++ ufw.service 2018-05-26 14:17:22.030681670 +0100
@@ -2,7 +2,7 @@
 Description=Uncomplicated firewall
 Documentation=man:ufw(8)
 DefaultDependencies=no
-Before=network.target
+After=network-pre.target

 [Service]
 Type=oneshot

According to this page

https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/

the network-pre.target has this purpose:

"It's primary purpose is for usage with firewall services that want to establish a firewall before any network interface is up"

Making the above change solves the problem so that ufw does seem to start up after boot. Is it a bug that ufw.service is not setup this way to start with?