/errors/ufw/couldnt-determine-iptables-version
ERROR: Couldn't determine iptables version
- tool
- ufw
- exit code
- 1
- versions
- ufw 0.36, ufw 0.36.2
- os
- linux
ERROR: Couldn't determine iptables version means ufw ran iptables -V to find out which iptables it is working with, and the command failed. The iptables binary is missing, or the iptables link points to something that cannot run. Install the iptables package and make sure iptables -V prints a version; on Debian and Ubuntu also check the update-alternatives link.
Where the message comes from
When ufw starts, its backend (src/backend.py) calls ufw.util.get_iptables_version(), which runs iptables -V from ufw's iptables directory (/usr/sbin on Debian and Ubuntu builds) and takes the version from the second word of the output. A non-zero exit status (or a binary that cannot be started) raises an error, which ufw reports as ERROR: Couldn't determine iptables version, and ufw exits with status 1. The check runs while ufw initialises its backend, so every command that uses the backend fails the same way, including ufw status.
Check iptables
iptables -V
ls -l /usr/sbin/iptables
update-alternatives --display iptablesA working system prints a line like iptables v1.8.x (nf_tables) or (legacy). If the binary is missing, install it (Debian, Ubuntu: apt-get install iptables; run as root). If the alternative points to a missing file, select an installed one:
update-alternatives --config iptables
update-alternatives --config ip6tablesUse the same backend (nft or legacy) for both, and the one the rest of the system uses (Docker, Kubernetes), so that all tools see the same rules.
In Docker, LXC and WSL
Minimal container images usually do not include iptables, and an unprivileged container cannot change the firewall even when it is installed. Configure the firewall on the host, or for Docker use published ports and Docker's own DOCKER-USER chain on the host. Under WSL 2, firewall rules for Windows applications belong in Windows Defender Firewall, not in ufw inside the Linux distribution.