Report this

What is the reason for this report?

Auto enable UFW on startup

Posted on June 24, 2015
Casy

By Casy

Hi everyone, i love this community!

Today i ask for help, i have a problem in my droplet. When i restart my server the Firewall UFW is always disabled. in my file: /etc/ufw/ufw.conf i have enabled to auto-start, but it does not work.

What can i do? can Ajenti/-V have something to do?

Thanks everyone!



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Ran into a problem with this answer, here is the fix.

@JonsJava suggested adding this line to /etc/rc.local

ufw eanble

however it is spelled incorrectly, it should be:

ufw enable

so, it took a while to debug this because rc.local doesn’t automatically log anywhere. if you add these lines to the top of rc.local, you will see the error with @JonsJava 's answer.

exec 2> /tmp/rc.local.log      # send stderr from rc.local to a log file
exec 1>&2                      # send stdout to the same log file
set -x                         # tell sh to display commands before execution

As @digitaldragon mentioned, this looks like it was a bug that has since been fixed. Here’s the changelog entry:

ufw (0.34~rc-0ubuntu4) utopic; urgency=medium

  * Install the SysV init and upstart script for both Debian and Ubuntu.
    Debian has upstart too, and in Ubuntu we need the init script for LSB
    dependencies and for systemd. (LP: #1341083)
    - Rename debian/ufw.init.debian to debian/ufw.init
    - Rename debian/ufw.upstart.ubuntu to debian/ufw.upstart
    - Remove all the distro specific code from debian/rules and just call
      dh_installinit.
  * Drop the distro specific logrotate configs, and use the ubuntu one with
    "rotate" instead of "reload" everywhere, as Debian's rsyslog init also
    supports "rotate".
  * Add a systemd unit:
    - Add debian/ufw.service
    - Add dh-systemd build dep.
    - debian/rulles: Call dh_systemd_{enable,start}.

 -- Martin Pitt <martin.pitt@ubuntu.com>   Wed, 30 Jul 2014 15:06:25 +0200

adding this line to /etc/rc.local fixed the issue for me

ufw enable

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.