Skip to content

nftables module: absorb into firewall module, rename ruleset options #161428

Description

@flokli

Problem statement

Right now, we have networking.nftables and networking.firewall.

However, at least since #81172 (which got shipped in 21.11) we kinda default to using nftables, and all ip[6]tables/arptables/ebtables invocations essentially only modify nf_tables rules under the hood.

This means, most of the things we do in the nftables NixOS module should also be done by default, not just if we set networking.nftables.enable to true:

    boot.blacklistedKernelModules = [ "ip_tables" ];
    environment.systemPackages = [ pkgs.nftables ];
    networking.networkmanager.firewallBackend = mkDefault "nftables";
  • It kinda makes sense to blacklist the kernel module.
  • We might want to have the nft binary in $PATH to be able to see and modify these rules (at least in the cases where we have iptables & Co. in $PATH).
  • Configuring NetworkManager to use the nftables backend also makes sense. systemd-networkd already does the same.

--

There's an assertion preventing us to enable both the NixOS firewall and the nftables module, as the nftables module also creates a systemd unit that tries to (exclusively) configure all nf_tables tables (which is dooned to fail, as there's other things inserting into it, such as systemd-networkd, and libvirt (through iptables-nft)

Proposed Fix(es)

  • Absorb the above three config options into the firewall module, and enable them when firewall is enabled
  • Move networking.nftables.ruleset and networking.nftables.rulesetFile somewhere below networking.firewall, with a big fat disclaimer (lib.warn?) stating this doesn't compose with the rest of the NixOS firewall, or other things interacting with the firewall, as it exclusively replaces everything whenever restarted.

cc @fpletz @misuzu @andir

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions