1 { pkgs, lib, config, machines, ... }:
3 inherit (builtins) hasAttr readFile;
4 inherit (pkgs.lib) unlinesAttrs;
5 inherit (config.users) users groups;
8 networking.firewall.enable = false;
9 security.lockKernelModules = false;
10 systemd.services.disable-kernel-module-loading.after = [ "nftables.service" ];
11 # echo -e "$(nix eval machines.losurdo.config.networking.nftables.ruleset)"
13 networking.nftables = {
15 ruleset = lib.mkBefore ''
18 # Some .nix append rules here with: add rule inet filter net2fw ...
21 tcp dport {80,443} counter accept comment "HTTP"
22 udp dport 123 skuid ${users.systemd-timesync.name} counter accept comment "NTP"
23 tcp dport 9418 counter accept comment "Git"
25 # Some .nix append rules here with: add rule inet filter fw2net ...
29 # Some .nix append rules here with: add rule inet filter lan2fw ...
33 # Some .nix append rules here with: add rule inet filter fw2lan ...
36 # Some .nix append rules here with: add rule inet filter intra2fw ...
39 # Some .nix append rules here with: add rule inet filter fw2intra ...
43 type filter hook input priority 0
48 # accept traffic already established
49 ct state {established, related} accept
53 tcp dport 22 counter accept comment "SSH"
54 udp dport 60000-61000 counter accept comment "Mosh"
57 #ip6 nexthdr icmpv6 icmpv6 type { destination-unreachable, packet-too-big, time-exceeded, parameter-problem, nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert, mld-listener-query, nd-router-solicit } accept
58 ip protocol icmp icmp type { destination-unreachable, router-advertisement, time-exceeded, parameter-problem } accept
61 #ip6 nexthdr icmpv6 icmpv6 type echo-request accept
62 ip protocol icmp icmp type echo-request accept
64 # Some .nix append gotos here with: add rule inet filter input iffname ... goto ...
67 type filter hook output priority 0
72 ct state {related,established} accept
75 icmp type echo-request counter accept comment "Ping"
76 tcp dport 22 counter accept comment "SSH"
78 # Some .nix append gotos here with: add rule inet filter output oifname ... goto ...
81 type filter hook forward priority 0