iptables cannot open the filter table in WSL, a container or on a bare kernel
Your error
iptables v1.8.10 (legacy): can't initialize iptables table `filter': Table does not exist (do you need to insmod?)2 more lines it can showFix it fast
Most common cause, 1 of 3The distribution runs on WSL 1
Convert the distribution to WSL 2 from PowerShell and make 2 the default for new ones.
wsl --set-version Ubuntu-24.04 2
wsl --set-default-version 2Short answer
iptables prints can't initialize iptables table `filter' when the kernel side of the firewall is missing or out of reach. With iptables 1.8 the cases are a WSL 1 distribution with no real Linux kernel, a user or container without the right to change rules (Permission denied), and the legacy backend on a kernel that lacks the old ip_tables table.
Which cause do you have?
Print the backend, your user id and, on Windows, the WSL version of the distribution. (legacy) or (nf_tables) in the version line, uid 0 or not, and a 1 or 2 in the WSL list point to different causes.
iptables --version
id -u
wsl.exe -l -vThen find the line you see in this list and open its fix:
- 1The distribution runs on WSL 1
wsl -l -v shows VERSION 1 for the distribution - 2The user or the container may not change firewall rules
Permission denied (you must be root), as a normal user on the host or as root inside a Docker container - 3The legacy backend runs on a kernel without the old ip_tables table
(legacy) in iptables --version, and Table does not exist (do you need to insmod?)
What does the error look like?
iptables v1.8.10 (legacy): can't initialize iptables table `filter': Table does not exist (do you need to insmod?)Perhaps iptables or your kernel needs to be upgraded.can't initialize iptables table `filter': Permission denied (you must be root)
Cause 1 of 3
The distribution runs on WSL 1
You seewsl -l -v shows VERSION 1 for the distribution
Check
can't initialize iptables table `filter' inside WSL 1 means there is no Linux kernel to hold the table. Microsoft's comparison marks WSL 1 as having neither a full Linux kernel nor full system call compatibility, since it runs Linux programs on a translation layer; WSL 2 has both.
wsl -l -vFix
Convert the distribution to WSL 2 from PowerShell and make 2 the default for new ones. Switching versions is slow for big distributions and may break midway, Microsoft notes, so back up large projects first.
wsl --set-version Ubuntu-24.04 2
wsl --set-default-version 2Verify
wsl -l -v shows VERSION 2, and inside the distribution sudo iptables -L -n lists the INPUT, FORWARD and OUTPUT chains.
sudo iptables -L -nConfirmed by learn.microsoft.com
Cause 2 of 3
The user or the container may not change firewall rules
You seePermission denied (you must be root), as a normal user on the host or as root inside a Docker container
Check
can't initialize iptables table `filter': Permission denied (you must be root) means the process lacks the right to manage network settings. On a host that is a missing sudo. Inside a container it is the NET_ADMIN capability, which Docker leaves out of its default set, so even root in the container is refused.
id -uFix
Run iptables with sudo on the host. For a container that has to manage rules, add only NET_ADMIN instead of running it with --privileged, which hands over every capability and almost full host access.
sudo iptables -L -n
docker run --rm -it --cap-add=NET_ADMIN my-firewall-imageVerify
iptables -L -n inside the new container prints the chains instead of Permission denied.
iptables -L -nConfirmed by docs.docker.com
Cause 3 of 3
The legacy backend runs on a kernel without the old ip_tables table
You see(legacy) in iptables --version, and Table does not exist (do you need to insmod?)
Check
can't initialize iptables table `filter': Table does not exist (do you need to insmod?) from the legacy backend means the kernel offers no legacy filter table, even after iptables tried to load the module itself. Debian has run iptables through the iptables-nft layer on nftables by default since Debian 10, and update-alternatives decides which variant the iptables command starts.
update-alternatives --display iptablesFix
Point iptables and ip6tables back at the nft variants, which work on the nftables side of the kernel.
sudo update-alternatives --set iptables /usr/sbin/iptables-nft
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-nftVerify
iptables --version now ends in (nf_tables), and sudo iptables -L -n lists the chains.
iptables --versionConfirmed by wiki.debian.org
How do I stop it coming back?
- Keep WSL distributions on version 2 (wsl --set-default-version 2) when they need firewall rules or Docker.
- Grant containers --cap-add=NET_ADMIN only when they manage rules, never --privileged for that alone.
- Choose one iptables variant per machine with update-alternatives and keep scripts and images on it.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: TaxiDex, Dispatch Pro.