UFW gets inactive on restart of container

Hi!

UFW runs fine here. Whenever the container is restarted, the UFW rules are applied automatically.
To make sense whether it works or not, we should have a common test.
Here it is,

  1. Launch a new container,

    lxc launch ubuntu:18.04 ufw
    
  2. Get a shell into the container and install a Web server.

    sudo apt update
    sudo apt install -y nginx
    logout
    
  3. Test that the Web server is accessible from the host.

    $ curl http://10.10.10.100/
    
    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    <style>
        body {
    
  4. Get back into the container and enable UFW.

    $ sudo ufw enable
    Firewall is active and enabled on system startup
    
  5. Then, try to access the web server from the host.

    $ curl http://10.10.10.100/
    
    (does not connect!)
    
  6. Restart the container and try to access again.

    $ lxc restart ufw
    $ curl http://10.10.10.100/
    
    (does not connect!)
1 Like