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
- Open a terminal or SSH session and log in to your Ubuntu 18.04 system.
- Use the following command to open the UFW service file in the Vim text editor:
|
|
-
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, pressdd
to delete the line, and then save the file and exit Vim by typing:wq
. -
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, presso
to start a new line, and then typeAfter=network.target
. Save the file and exit Vim by typing:wq
.
Enabling the UFW Service
- After modifying the UFW service file, you need to reload the systemd daemon configuration to ensure the changes take effect. Run the following command:
|
|
- Now, enable the UFW service to start on boot by running the following command:
|
|
- Finally, reboot your system:
|
|
- 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.