wireguard: initial setup

This commit is contained in:
Katherina Walshe-Grey 2024-07-19 19:26:36 +01:00
parent 35563b1b07
commit c60728e7aa
10 changed files with 99 additions and 4 deletions

View file

@ -4,6 +4,7 @@
imports = [
./hardware-configuration.nix
./home.nix
./wireguard.nix
];
boot.loader.systemd-boot.enable = true;

33
hosts/orm/wireguard.nix Normal file
View file

@ -0,0 +1,33 @@
{ config, lib, pkgs, ... }:
{
age.secrets.wireguard-hub.file = ../../secrets/wireguard-hub.age;
networking = {
nat = {
enable = true;
externalInterface = "ens3";
internalInterfaces = [ "wg0" ];
};
firewall.allowedUDPPorts = [ config.networking.wireguard.interfaces.wg0.listenPort ];
wireguard.interfaces.wg0 = {
ips = [ "10.127.1.1/24" "fd70:81ca:0f8f:1::1/64" ];
listenPort = 51820;
privateKeyFile = config.age.secrets.wireguard-hub.path;
peers = [
{
name = "shaw";
publicKey = "eD79pROC2zjhKz4tGRS43O95gcFRqO+SFb2XDnTr0zc=";
allowedIPs = [ "10.127.1.2" "fd70:81ca:0f8f:1::2" ];
}
{
name = "tohru";
publicKey = "lk3PCQM1jmZoI8sM/rWSyKNuZOUnjox3n9L9geJD+18=";
allowedIPs = [ "10.127.1.3" "fd70:81ca:0f8f:1::3" ];
}
];
};
};
}

View file

@ -9,6 +9,7 @@
../../services/fonts.nix
../../services/steam.nix
./syncthing.nix
./wireguard.nix
];
boot.loader.systemd-boot.enable = true;

23
hosts/tohru/wireguard.nix Normal file
View file

@ -0,0 +1,23 @@
{ config, lib, pkgs, ... }:
{
age.secrets.wireguard-peer-tohru.file = ../../secrets/wireguard-peer-tohru.age;
networking = {
firewall.allowedUDPPorts = [ config.networking.wireguard.interfaces.wg0.listenPort ];
wireguard.interfaces.wg0 = {
ips = [ "10.127.1.3/24" "fd70:81ca:0f8f:1::3/64" ];
listenPort = 51821;
privateKeyFile = config.age.secrets.wireguard-peer-tohru.path;
peers = [
{
publicKey = "birdLVh8roeZpcVo308Ums4l/aibhAxbi7MBsglkJyA=";
allowedIPs = [ "10.127.1.0/24" "fd70:81ca:0f8f:1::/64" ];
endpoint = "birdsong.network:51820";
persistentKeepalive = 23;
}
];
};
};
}