1 { pkgs, lib, config, ... }:
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 systemd.services.disable-kernel-module-loading.after = [ "nftables.service" ];
11 systemd.services.nftables.serviceConfig.TimeoutStartSec = "20";
12 networking.nftables = {
14 ruleset = lib.mkBefore ''
16 include "${../../../networking/nftables/filter.txt}"
17 # A set containing the udp port(s) to which SSDP replies are allowed.
23 #udp dport mdns ip6 daddr ff02::fb counter accept comment "Accept mDNS"
24 #udp dport mdns ip daddr 224.0.0.251 counter accept comment "Accept mDNS"
27 #ct state new add @connlimit { ip saddr ct count over 20 } counter tcp reject with tcp reset
29 # Some .nix append rules here with: add rule inet filter net2fw ...
32 tcp dport { 80, 443 } counter accept comment "HTTP"
33 udp dport 123 skuid ${users.systemd-timesync.name} counter accept comment "NTP"
34 tcp dport 1965 counter accept comment "Gemini"
35 tcp dport 9418 counter accept comment "Git"
37 # Some .nix append rules here with: add rule inet filter fw2net ...
40 # Some .nix append rules here with: add rule inet filter wifi2fw ...
43 # Some .nix append rules here with: add rule inet filter fw2wifi ...
46 # Some .nix append rules here with: add rule inet filter fwd-wifi ...
49 # Some .nix append rules here with: add rule inet filter intra2fw ...
52 # Some .nix append rules here with: add rule inet filter fw2intra ...
55 # Some .nix append rules here with: add rule inet filter fwd-intra ...
58 # Some .nix append rules here with: add rule inet filter extra2fw ...
62 type filter hook input priority filter
68 ct state { established, related } accept
69 jump accept-connectivity-input
70 ct state invalid counter drop
73 tcp dport 22 counter accept comment "SSH"
74 udp dport 60000-61000 counter accept comment "Mosh"
76 # Some .nix append gotos here with: add rule inet filter input iffname ... goto ...
79 type filter hook forward priority filter
82 #tcp flags syn tcp option maxseg size set rt mtu
83 ct state { related, established } accept
84 jump accept-connectivity-forward
87 type filter hook output priority filter
92 tcp flags syn tcp option maxseg size set rt mtu
94 ct state { related, established } accept
95 jump accept-connectivity-output
97 tcp dport 22 counter accept comment "SSH"
99 # Some .nix append gotos here with: add rule inet filter output oifname ... goto ...
104 type nat hook prerouting priority filter
108 type nat hook postrouting priority srcnat