Skip to content

netns-isolation: require the iptables firewall backend - #169

Merged
seberm merged 2 commits into
bitcoinix:masterfrom
ostermayer:netns-iptables-backend
Oct 27, 2026
Merged

seberm merged 2 commits into
bitcoinix:masterfrom
ostermayer:netns-iptables-backend

Conversation

@ostermayer

@ostermayer ostermayer commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #160.

netns-isolation.nix runs its rules with ${config.networking.firewall.package}/bin/iptables. NixOS sets that package to pkgs.nftables as soon as networking.nftables.enable = true, and nftables ships no iptables binary, so nb-netns-bridge died on its first rule and every netns service stayed down with nothing to say why.

What changed:

  • An assertion in the module requires networking.firewall.backend == "iptables", the same check the wireguard preset already has, with a message that says to disable networking.nftables and services.firewalld. The host firewall may stay off, the netns rules run inside the namespaces and only the nat MASQUERADE rule touches the host.
  • New configuration check testNetnsRejectsNftables: a netns node with nftables on must fail with that message. The existing testNetnsRESTAllowed keeps checking that the default netns node has no failed assertions.

firewalld is rejected too. With firewalld and nftables off the package would still be iptables, so the bridge would probably work, but the preset already treats firewalld as unsupported and the two checks should agree.

Tested

  • module-config passes on this branch (30 tests) and testNetnsRejectsNftables fails on master with only the test added, both built on x86_64-linux.
  • nix flake check and the VM scenarios run in CI.

Codex (GPT-6 Astra, xhigh) reviewed the commits. It confirmed the option name and the default chain in the pinned nixpkgs firewall module and caught the first message blaming firewalld for the missing binary, fixed in the second commit. DeepSeek V4.1 Flash 1017 (max) and GLM 5.3 (max) audited the tree at 3909bee with Astra as the second opinion, and GLM audited dfac0f3: five and three findings. Two touch netns-isolation.nix and neither is about the assertion. GLM repeats the module's own TODO that service ids aren't checked for uniqueness (line 20), which predates this PR, and Astra adds that a collision would also hand one service the other's source IP allowance. DeepSeek claimed that mempool without the frontend fails to evaluate at line 307. Astra evaluated that configuration with the pinned inputs and marked it a false positive. The rest are #127, #124 and an info note that RTL writes its config with the default umask.

@github-actions github-actions Bot added area: ci .github/, test/, dev/ area: modules modules/ and pkgs/lib.nix labels Oct 27, 2026
@seberm seberm added the type: bug Behaviour is wrong vs. documented or intended label Oct 27, 2026
The module builds its iptables commands from networking.firewall.package.
With networking.nftables.enable NixOS sets that package to nftables, which
has no iptables binary, so nb-netns-bridge failed on its first rule and
every netns service stayed down, with nothing to say why.

Assert the iptables backend the way the wireguard preset does, and add a
configuration check for a netns node with nftables on.

Fixes bitcoinix#160
The package is nftables only when networking.nftables is enabled. With the
firewalld backend and nftables off it stays iptables, so the message
should not claim otherwise. firewalld is simply not supported.
@seberm
seberm force-pushed the netns-iptables-backend branch from dfac0f3 to 4fcfc9d Compare October 27, 2026 22:31
@seberm
seberm merged commit 0d73c69 into bitcoinix:master Oct 27, 2026
17 checks passed
seberm pushed a commit that referenced this pull request Oct 29, 2026
…bles

The assertion from #169 checked networking.firewall.backend only.
networking.firewall.package follows networking.nftables.enable, not the
backend, so a host with nftables enabled and the backend set to
"iptables" by hand passed evaluation and still ran the netns rules with
the nftables package, which has no iptables binary. The bridge unit
failed and every netns service stayed down.

Check networking.nftables.enable as well and add the configuration test
for that combination.
seberm added a commit that referenced this pull request Oct 29, 2026
…175)

netns-isolation: check the firewall package the netns rules run with (#175)

The assertion from #169 checked networking.firewall.backend only. In the
pinned nixpkgs networking.firewall.package follows networking.nftables.enable,
not the backend, so a host with nftables on and the backend set to
"iptables" by hand passed evaluation and still ran the netns rules with
the nftables package. That package has no iptables binary, so
nb-netns-bridge failed and every netns service stayed down. The old
message even pointed at that setting.

The assertion now also requires that the firewall package is not
nftables. An explicit networking.firewall.package = pkgs.iptables next to
nftables provides the binary and passes, so an operator who keeps the
iptables firewall and adds separate nftables tables isn't locked out.
The message names that override as the second way out.

Two configuration checks cover nftables with the iptables backend
(rejected) and the same with pkgs.iptables (accepted). Systems that
already evaluated are unchanged; only the broken combination is now
refused at evaluation time.

Follow-up to #169.
msgilligan pushed a commit to msgilligan/bitcoinix that referenced this pull request Nov 8, 2026
…bles

The assertion from bitcoinix#169 checked networking.firewall.backend only.
networking.firewall.package follows networking.nftables.enable, not the
backend, so a host with nftables enabled and the backend set to
"iptables" by hand passed evaluation and still ran the netns rules with
the nftables package, which has no iptables binary. The bridge unit
failed and every netns service stayed down.

Check networking.nftables.enable as well and add the configuration test
for that combination.
@ostermayer
ostermayer deleted the netns-iptables-backend branch November 8, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci .github/, test/, dev/ area: modules modules/ and pkgs/lib.nix type: bug Behaviour is wrong vs. documented or intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

netns-isolation: enabling nftables leaves the firewall package without an iptables binary, so the netns bridge never comes up

2 participants