enable wireguard

This commit is contained in:
Adithya 2024-03-31 22:28:56 +05:30
parent a2867486cd
commit e3a66faf21
Signed by: adtya
GPG key ID: B8857BFBA2C47B9C
2 changed files with 34 additions and 0 deletions

View file

@ -1,4 +1,8 @@
{ lib, ... }: {
imports = [
./wireguard.nix
];
networking = {
firewall = {
allowedTCPPorts = [

View file

@ -0,0 +1,30 @@
{ secrets, ... }:
let
wireguard_server = (secrets.wireguard_server // {
persistentKeepalive = 20;
allowedIPs = [
"10.10.10.0/24"
"fd7c:585c:c4ae::0/64"
];
});
in
{
networking.firewall.trustedInterfaces = [ "wg0" ];
networking.wireguard = {
enable = true;
interfaces = {
wg0 = {
ips = [
"10.10.10.2/24"
"fd7c:585c:c4ae::2/64"
];
listenPort = 51822;
privateKeyFile = "/etc/wireguard/private.key";
generatePrivateKeyFile = true;
peers = [
wireguard_server
];
};
};
};
}