1

I am running servers on several Pi's for VPN, OpenTTD, etc. I have installed ufw on all of them to try and keep them a little more secure. The server running the VPN is causing some issues as ufw doesn't start after a reboot, even though it is supposedly enabled.

Here is /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=high

Running sudo ufw status after a reboot I get:

Status: inactive

But running systemctl status ufw I get:

● ufw.service - Uncomplicated firewall
   Loaded: loaded (/lib/systemd/system/ufw.service; enabled; vendor preset: enabled)
   Active: active (exited) since Wed 2019-03-27 02:06:36 GMT; 4min 46s ago
     Docs: man:ufw(8)
  Process: 104 ExecStart=/lib/ufw/ufw-init start quiet (code=exited, status=0/SUCCESS)
 Main PID: 104 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/ufw.service

Mar 27 02:06:36 PiVPN systemd[1]: Started Uncomplicated firewall.
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

If I manually disable ufw and then try to re-enable it, I get the following error (The sudo ufw enable is done after a reboot):

ERROR: problem running ufw-init
ip6tables-restore: line 2 failed

I've been struggling with this issue for a while now, so any help would be greatly appreciated. Thanks.

EDIT 01: I have tried running sudo /usr/share/ufw/check-requirements and after some output, I get a message that All tests passed.

EDIT 02: I have done a complete re-install of ufw using sudo apt remove --purge ufw, and after installing it again the problem still persists.

  • have you tried sudo ufw reload and sudo ufw enable? – Dougie Mar 27 at 7:26
  • @Dougie If I run sudo ufw reload after a reboot, It says Firewall not enabled (skipping reload). If I manually enable it, I still get the same error: ERROR: problem running ufw-init ip6tables-restore: line 2 failed. – NathanielJS Mar 27 at 12:16
  • @Dougie sorry I should clarify, when I said "If I manually enable it", I meant if I manually do sudo ufw enable and then sudo ufw reload. I still get the same error. – NathanielJS Mar 27 at 14:13
1

Solution was found after a lot of digging. This bug report explained that ufw was trying to start before all of the network interfaces were up. This can be negated by doing one of the following:

From the Terminal
1. Type sudo raspi-config
2. Select Boot Options (Option 3)
3. Select Wait for Network at Boot (Option B2)
4. Select Yes

From the Desktop
1. Click Menu at the top left of the screen (The small raspberry icon)
2. Select Preferences
3. Select Raspberry Pi Configuration
4. Check the box next to Wait for network

Then enable ufw again and try rebooting. Use sudo ufw status to see if it has started.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.