summaryrefslogtreecommitdiff
path: root/hosts/apocalypse/firewall.nix
blob: 8c5dadbab72f91353678e55144585d1d7c3aa8a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{ pkgs, config, ... }:
let
  baseTCP = [
    22000 # Syncthng
    5352 # Zeroconf for spotifyd
  ];
  baseUDP = [
    22000 # Syncthing
    22027 # Syncthing
    16555 # Wireguard
    5353 # Mdns (Spotify)
  ];
  baseTCPRanges = [
    {
      from = 1714;
      to = 1764;
    } # KDE-CONNECT
  ];
  baseUDPRanges = [
    {
      from = 1714;
      to = 1764;
    } # KDE-CONNECT
  ];

  secureTCP = [
    22
    80
    433
    5900 # SSH HTTP VNC
  ];

  secureUDP = [
    5900
  ];

  secureTCPRanges = [

  ];
  secureUDPRanges = [

  ];
in
{
  networking.nftables.enable = true;
  networking.firewall = {
    enable = true;
    checkReversePath = false;
    allowedTCPPorts = baseTCP;
    allowedUDPPorts = baseUDP;
    allowedUDPPortRanges = baseUDPRanges;
    allowedTCPPortRanges = baseTCPRanges;
    interfaces = {
      "nix-laptop" = {
        allowedTCPPorts = secureTCP;
        allowedUDPPorts = secureUDP;
        allowedUDPPortRanges = secureUDPRanges;
        allowedTCPPortRanges = secureTCPRanges;
      };
    };
    trustedInterfaces = [
      "docker0"
      "br-*"
      "veth*"
      "vnet*"
      "virbr*"
    ];

  };
}