From 19068d52b5fc4c199bd9776abd96b21476c2c6dd Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Mon, 9 Aug 2021 18:24:06 -0400 Subject: vpn stuff --- modules/vpn.nix | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 modules/vpn.nix (limited to 'modules') diff --git a/modules/vpn.nix b/modules/vpn.nix new file mode 100644 index 0000000..fb6fd3a --- /dev/null +++ b/modules/vpn.nix @@ -0,0 +1,34 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.orbekk.vpn; +in +{ + options = { + orbekk.vpn = { + 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.vpn = { + privateKeyFile = "/opt/secret/wireguard/vpn.private"; + ips = [ "10.70.90.245/32" "fc00:bbbb:bbbb:bb01::7:5af4/128" ]; + allowedIPsAsRoutes = false; + listenPort = cfg.listenPort; + peers = [ + ]; + }; + }; + }; +} -- cgit v1.2.3