summaryrefslogtreecommitdiff
path: root/modules/mullvad.nix
blob: 5d531570c5eb81396dacb18b4d990f7af62b0b0e (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
{ config, lib, pkgs, ... }:

let
  cfg = config.orbekk.mullvad;
in
{
  options = {
    orbekk.mullvad = {
      enable = lib.mkEnableOption "Enable VPN";

      listenPort = lib.mkOption {
        type = lib.types.port;
        default = 40421;
        description = "wireguard local port";
      };
    };
  };

  config = lib.mkIf cfg.enable {
    orbekk.simple-firewall.allowedUDPPorts = [ cfg.listenPort ];

    networking.wireguard = {
      enable = true;
      interfaces.mullvad = {
        privateKeyFile = "/opt/secret/wireguard/mullvad.private";
        ips = [ "10.64.128.156/32" "fc00:bbbb:bbbb:bb01::1:809b/128" ];
        allowedIPsAsRoutes = false;
        listenPort = cfg.listenPort;
        peers = [
          # Oslo
          # {
          #   endpoint = "no4-wireguard.relays.mullvad.net:51820";
          #   publicKey = "veeEoYS9a2T6K8WMs/MvRCdNJG580XbhnLfbFjp3B0M=";
          #   allowedIPs = [ "0.0.0.0/0" "::0/0" ];
          # }
          # NYC
          {
            # us276
            endpoint = "146.70.171.130:51820";
            publicKey = "78nFhfPEjrfOxBkUf2ylM7w6upYBEcHXm93sr8CMTE4=";
            allowedIPs = [ "0.0.0.0/0" "::0/0" ];
          }
        ];
      };
    };
  };
}