use secrets file for key directly, since we have control of the server ephemeral key is less useful

This commit is contained in:
Haak Saxberg 2022-11-12 22:47:22 -08:00
parent fe39e730ae
commit a55e5da509

View file

@ -105,37 +105,45 @@ in
deployment.keys.wireguard.text = builtins.readFile ../../secrets/wireguard/svalbard; deployment.keys.wireguard.text = builtins.readFile ../../secrets/wireguard/svalbard;
# Enable WireGuard # Enable WireGuard
networking.wg-quick.interfaces = { networking.wg-quick.interfaces =
# "wg0" is the network interface name. You can name the interface arbitrarily. let
wg0 = { # Public key of the server (not a file path).
# Determines the IP address and subnet of the client's end of the tunnel interface. publicKey = "5y66WShsFXqM5K7/4CPEGCWfk7PQyNhVBT2ILjbGm2I=";
address = [ "10.64.168.213/32" "fc00:bbbb:bbbb:bb01::1:a8d4/128" ]; in
dns = [ "10.64.0.1" ]; {
listenPort = 51820; # to match firewall allowedUDPPorts (without this wg uses random port numbers) # "wg0" is the network interface name. You can name the interface arbitrarily.
wg0 = {
# Determines the IP address and subnet of the client's end of the tunnel interface.
address = [ "10.64.168.213/32" "fc00:bbbb:bbbb:bb01::1:a8d4/128" ];
dns = [ "10.64.0.1" ];
listenPort = 51820; # to match firewall allowedUDPPorts (without this wg uses random port numbers)
# Note: The private key can also be included inline via the privateKey option, # Note: The private key can also be included inline via the privateKey option,
# but this makes the private key world-readable; thus, using privateKeyFile is # but this makes the private key world-readable; thus, using privateKeyFile is
# recommended. # recommended.
privateKeyFile = "/run/keys/wireguard"; #privateKeyFile = "/run/keys/wireguard";
# See https://nixos.wiki/wiki/WireGuard#Tunnel_does_not_automatically_connect_despite_persistentKeepalive_being_set
# postUp = [ "wg set wg0 peer ${publicKey} persistent-keepalive 25" ];
privateKey = builtins.readFile ../../secrets/wireguard/svalbard;
# For a client configuration, one peer entry for the server will suffice. # For a client configuration, one peer entry for the server will suffice.
peers = [ peers = [
# Sweden, Malmo, se15 # Sweden, Malmo, se15
{ {
# Public key of the server (not a file path). inherit publicKey;
publicKey = "5y66WShsFXqM5K7/4CPEGCWfk7PQyNhVBT2ILjbGm2I=";
# Forward all the traffic via VPN. # Forward all the traffic via VPN.
allowedIPs = [ "0.0.0.0/0" "::0/0" ]; allowedIPs = [ "0.0.0.0/0" "::0/0" ];
# Set this to the server IP and port. # Set this to the server IP and port.
endpoint = "193.138.218.80:51820"; # ToDo: route to endpoint not automatically configured https://wiki.archlinux.org/index.php/WireGuard#Loop_routing https://discourse.nixos.org/t/solved-minimal-firewall-setup-for-wireguard-client/7577 endpoint = "193.138.218.80:51820"; # ToDo: route to endpoint not automatically configured https://wiki.archlinux.org/index.php/WireGuard#Loop_routing https://discourse.nixos.org/t/solved-minimal-firewall-setup-for-wireguard-client/7577
# Send keepalives every 25 seconds. Important to keep NAT tables alive. # Send keepalives every 25 seconds. Important to keep NAT tables alive.
persistentKeepalive = 25; # see https://nixos.wiki/wiki/WireGuard#Tunnel_does_not_automatically_connect_despite_persistentKeepalive_being_set
} persistentKeepalive = 25;
]; }
];
};
}; };
};
}; };
} }