1 { pkgs, lib, config, machines, ... }:
3 inherit (builtins) hasAttr readFile;
4 inherit (pkgs.lib) unlinesAttrs;
5 inherit (config) networking;
6 inherit (config.users) users groups;
9 networking.firewall.enable = false;
10 security.lockKernelModules = false;
11 systemd.services.disable-kernel-module-loading.after = [ "nftables.service" ];
12 systemd.services.nftables.serviceConfig.TimeoutStartSec = "20";
13 networking.nftables = {
15 ruleset = lib.mkBefore ''
17 include "${../../../var/nftables/filter.txt}"
19 #udp dport mdns ip6 daddr ff02::fb counter accept comment "Accept mDNS"
20 #udp dport mdns ip daddr 224.0.0.251 counter accept comment "Accept mDNS"
23 #ct state new add @connlimit { ip saddr ct count over 20 } counter tcp reject with tcp reset
25 # Some .nix append rules here with: add rule inet filter net2fw ...
28 tcp dport { 80, 443 } counter accept comment "HTTP"
29 udp dport 123 skuid ${users.systemd-timesync.name} counter accept comment "NTP"
30 tcp dport 1965 counter accept comment "Gemini"
31 tcp dport 9418 counter accept comment "Git"
33 # Some .nix append rules here with: add rule inet filter fw2net ...
36 # Some .nix append rules here with: add rule inet filter wifi2fw ...
39 # Some .nix append rules here with: add rule inet filter fw2wifi ...
42 # Some .nix append rules here with: add rule inet filter fwd-wifi ...
45 # Some .nix append rules here with: add rule inet filter intra2fw ...
48 # Some .nix append rules here with: add rule inet filter fw2intra ...
51 # Some .nix append rules here with: add rule inet filter fwd-intra ...
54 # Some .nix append rules here with: add rule inet filter extra2fw ...
58 type filter hook input priority filter
64 ct state { established, related } accept
65 jump accept-connectivity-input
66 ct state invalid counter drop
69 tcp dport 22 counter accept comment "SSH"
70 udp dport 60000-61000 counter accept comment "Mosh"
72 # Some .nix append gotos here with: add rule inet filter input iffname ... goto ...
75 type filter hook forward priority filter
78 ct state { related, established } accept
79 jump accept-connectivity-forward
82 type filter hook output priority filter
87 ct state { related, established } accept
88 jump accept-connectivity-output
90 tcp dport 22 counter accept comment "SSH"
92 # Some .nix append gotos here with: add rule inet filter output oifname ... goto ...
97 type nat hook prerouting priority filter
101 type nat hook postrouting priority srcnat