UFW Not Starting on Boot in Ubuntu 18.04

If you’re experiencing issues with the Uncomplicated Firewall (UFW) not starting on boot in Ubuntu 18.04, there are a few steps you can take to troubleshoot and resolve the problem. Here’s a step-by-step guide to fix the issue.

Please note: Modifying system files requires administrative privileges. Make sure you have the necessary permissions before proceeding.

Editing the UFW Service File

  1. Open a terminal or SSH session and log in to your Ubuntu 18.04 system.
  2. Use the following command to open the UFW service file in the Vim text editor:
1
sudo vim /lib/systemd/system/ufw.service
  1. Inside the Vim editor, locate the line that reads Before=network.target. You need to remove this line from the file. To do so, move the cursor to that line, press dd to delete the line, and then save the file and exit Vim by typing :wq.

  2. Next, you need to add the line After=network.target to the UFW service file. To do this, move the cursor to an empty line after the [Service] section, press o to start a new line, and then type After=network.target. Save the file and exit Vim by typing :wq.

Enabling the UFW Service

  1. After modifying the UFW service file, you need to reload the systemd daemon configuration to ensure the changes take effect. Run the following command:
1
sudo systemctl daemon-reload
  1. Now, enable the UFW service to start on boot by running the following command:
1
sudo systemctl enable ufw
  1. Finally, reboot your system:
1
sudo reboot
  1. After the system restarts, UFW should be started automatically during the boot process.

Conclusion

By removing the Before=network.target line and adding the After=network.target line in the UFW service file, you can ensure that UFW starts on boot in Ubuntu 18.04. Remember to reload the systemd daemon configuration and enable the UFW service before rebooting the system.

If you encounter any issues or the problem persists, please consult the official Ubuntu documentation or seek assistance from the Ubuntu community forums for further support.

0%