Public bug reported:

I've an Ubuntu 22.04 LTS machine here where

    apt purge iptables-persistent
    apt purge netfilter-persistent
    apt purge ufw
    apt install ufw
    ufw allow ssh
    ufw allow 3344/tcp
    ufw enable

results in this output:

    Command may disrupt existing ssh connections. Proceed with operation (y|n)? 
y
    ERROR: problem running ufw-init
    iptables-restore: line 4 failed

and the machine is no longer reachable over the network, with iptables
-nL (in a local shell) printing

    Chain INPUT (policy DROP)
    target     prot opt source               destination

    Chain FORWARD (policy DROP)
    target     prot opt source               destination

    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination

    Chain ufw-after-forward (0 references)
    target     prot opt source               destination

    Chain ufw-after-input (0 references)
    target     prot opt source               destination
    ufw-skip-to-policy-input  udp  --  0.0.0.0/0            0.0.0.0/0           
 udp dpt:137
    ufw-skip-to-policy-input  udp  --  0.0.0.0/0            0.0.0.0/0           
 udp dpt:138
    ufw-skip-to-policy-input  tcp  --  0.0.0.0/0            0.0.0.0/0           
 tcp dpt:139
    ufw-skip-to-policy-input  tcp  --  0.0.0.0/0            0.0.0.0/0           
 tcp dpt:445
    ufw-skip-to-policy-input  udp  --  0.0.0.0/0            0.0.0.0/0           
 udp dpt:67
    ufw-skip-to-policy-input  udp  --  0.0.0.0/0            0.0.0.0/0           
 udp dpt:68
    ufw-skip-to-policy-input  all  --  0.0.0.0/0            0.0.0.0/0           
 ADDRTYPE match dst-type BROADCAST

    Chain ufw-after-logging-forward (0 references)
    target     prot opt source               destination
    LOG        all  --  0.0.0.0/0            0.0.0.0/0            limit: avg 
3/min burst 10 LOG flags 0 level 4 prefix "[UFW BLOCK] "

    Chain ufw-after-logging-input (0 references)
    target     prot opt source               destination

    Chain ufw-after-logging-output (0 references)
    target     prot opt source               destination

    Chain ufw-after-output (0 references)
    target     prot opt source               destination

    Chain ufw-before-forward (0 references)
    target     prot opt source               destination
    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            ctstate 
RELATED,ESTABLISHED
    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0            icmptype 3
    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0            icmptype 11
    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0            icmptype 12
    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0            icmptype 8
    ufw-user-forward  all  --  0.0.0.0/0            0.0.0.0/0

    Chain ufw-before-input (0 references)
    target     prot opt source               destination
    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            ctstate 
RELATED,ESTABLISHED
    ufw-logging-deny  all  --  0.0.0.0/0            0.0.0.0/0            
ctstate INVALID
    DROP       all  --  0.0.0.0/0            0.0.0.0/0            ctstate 
INVALID
    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0            icmptype 3
    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0            icmptype 11
    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0            icmptype 12
    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0            icmptype 8
    ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0            udp spt:67 
dpt:68
    ufw-not-local  all  --  0.0.0.0/0            0.0.0.0/0
    ACCEPT     udp  --  0.0.0.0/0            224.0.0.251          udp dpt:5353
    ACCEPT     udp  --  0.0.0.0/0            239.255.255.250      udp dpt:1900
    ufw-user-input  all  --  0.0.0.0/0            0.0.0.0/0

    Chain ufw-before-logging-forward (0 references)
    target     prot opt source               destination

    Chain ufw-before-logging-input (0 references)
    target     prot opt source               destination

    Chain ufw-before-logging-output (0 references)
    target     prot opt source               destination

    Chain ufw-before-output (0 references)
    target     prot opt source               destination
    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            ctstate 
RELATED,ESTABLISHED
    ufw-user-output  all  --  0.0.0.0/0            0.0.0.0/0

    Chain ufw-logging-allow (0 references)
    target     prot opt source               destination
    LOG        all  --  0.0.0.0/0            0.0.0.0/0            limit: avg 
3/min burst 10 LOG flags 0 level 4 prefix "[UFW ALLOW] "

    Chain ufw-logging-deny (2 references)
    target     prot opt source               destination
    RETURN     all  --  0.0.0.0/0            0.0.0.0/0            ctstate 
INVALID limit: avg 3/min burst 10
    LOG        all  --  0.0.0.0/0            0.0.0.0/0            limit: avg 
3/min burst 10 LOG flags 0 level 4 prefix "[UFW BLOCK] "

    Chain ufw-not-local (1 references)
    target     prot opt source               destination
    RETURN     all  --  0.0.0.0/0            0.0.0.0/0            ADDRTYPE 
match dst-type LOCAL
    RETURN     all  --  0.0.0.0/0            0.0.0.0/0            ADDRTYPE 
match dst-type MULTICAST
    RETURN     all  --  0.0.0.0/0            0.0.0.0/0            ADDRTYPE 
match dst-type BROADCAST
    ufw-logging-deny  all  --  0.0.0.0/0            0.0.0.0/0            limit: 
avg 3/min burst 10
    DROP       all  --  0.0.0.0/0            0.0.0.0/0

    Chain ufw-skip-to-policy-forward (0 references)
    target     prot opt source               destination
    DROP       all  --  0.0.0.0/0            0.0.0.0/0

    Chain ufw-skip-to-policy-input (7 references)
    target     prot opt source               destination
    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0

    Chain ufw-skip-to-policy-output (0 references)
    target     prot opt source               destination
    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0

    Chain ufw-user-forward (1 references)
    target     prot opt source               destination

    Chain ufw-user-input (1 references)
    target     prot opt source               destination
    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:22
    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:3344

    Chain ufw-user-limit (0 references)
    target     prot opt source               destination
    LOG        all  --  0.0.0.0/0            0.0.0.0/0            limit: avg 
3/min burst 5 LOG flags 0 level 4 prefix "[UFW LIMIT BLOCK] "
    REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with 
icmp-port-unreachable

    Chain ufw-user-limit-accept (0 references)
    target     prot opt source               destination
    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0

    Chain ufw-user-logging-forward (0 references)
    target     prot opt source               destination

    Chain ufw-user-logging-input (0 references)
    target     prot opt source               destination

    Chain ufw-user-logging-output (0 references)
    target     prot opt source               destination

    Chain ufw-user-output (1 references)
    target     prot opt source               destination

If I run `ufw status` it lies to me, claiming that there are rules allowing 
incoming ports 22 and 3344.
If I run `ufw disable; ufw enable` locally I see two lines of iptables-restore 
complaints instead of just one:

    ERROR: problem running ufw-init
    iptables-restore: line 4 failed
    iptables-restore: line 4 failed

The problem started appearing after a reboot yesterday; the initial
firewall setup `sudo apt install ufw; sudo ufw allow sshl sudo ufw
enable` happened two days ago and everything worked as expected until
the reboot.  A number of package updates were installed before the
reboot, including systemd, netplan, fwupd, iproute2, cloud-init,
dnsmasq-base, which might or might not be relevant.

As a workaround I've temporarily set the DEFAULT_INPUT_POLICY="ACCEPT"
in /etc/default/ufw, since it's not fun being unable to ssh into a
machine.

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: ufw 0.36.1-4ubuntu0.1
ProcVersionSignature: Ubuntu 6.8.0-138.138~22.04.1-generic 6.8.12
Uname: Linux 6.8.0-138-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.10
Architecture: amd64
CasperMD5CheckMismatches: ./boot/grub/grub.cfg
CasperMD5CheckResult: fail
CloudArchitecture: x86_64
CloudID: none
CloudName: none
CloudPlatform: none
CloudSubPlatform: config
Date: Fri Oct 16 13:18:39 2026
InstallationDate: Installed on 2024-07-25 (813 days ago)
InstallationMedia: Ubuntu-Server 22.04.2 LTS "Jammy Jellyfish" - Release amd64 
(20230217.1)
PackageArchitecture: all
ProcEnviron:
 TERM=screen.xterm-256color
 PATH=(custom, no user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: ufw
UpgradeStatus: No upgrade log present (probably fresh install)
mtime.conffile..etc.default.ufw: 2026-10-16T13:05:52.957896

** Affects: ufw (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug jammy uec-images

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2171087

Title:
  `ufw enable` sets policy but doesn't add any rules, fails with "ERROR:
  problem running ufw-init", leaves machine unreachable over SSH

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ufw/+bug/2171087/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to