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
Problem statement
Right now, we have
networking.nftablesandnetworking.firewall.However, at least since #81172 (which got shipped in 21.11) we kinda default to using nftables, and all
ip[6]tables/arptables/ebtablesinvocations essentially only modifynf_tablesrules under the hood.This means, most of the things we do in the
nftablesNixOS module should also be done by default, not just if we setnetworking.nftables.enableto true:nftbinary in$PATHto be able to see and modify these rules (at least in the cases where we haveiptables& Co. in$PATH).nftablesbackend 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_tablestables (which is dooned to fail, as there's other things inserting into it, such as systemd-networkd, and libvirt (throughiptables-nft)Proposed Fix(es)
networking.nftables.rulesetandnetworking.nftables.rulesetFilesomewhere belownetworking.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