2023-12-05 05:27:06 +01:00
|
|
|
{ pkgs, config, lib, ... }: {
|
2023-12-11 13:07:16 +01:00
|
|
|
|
|
|
|
# Allow these hosts to directly communicate with their hostnames
|
2023-12-11 13:09:56 +01:00
|
|
|
networking.extraHosts = ''
|
2023-12-11 13:07:16 +01:00
|
|
|
10.100.0.1 osaka-linode-01
|
|
|
|
10.100.0.2 framework-server
|
2024-01-29 03:39:49 +01:00
|
|
|
10.100.0.3 backups-rpi4
|
2023-12-13 03:40:30 +01:00
|
|
|
|
|
|
|
10.100.0.2 git.sysctl.io
|
2023-12-11 13:15:25 +01:00
|
|
|
10.100.0.2 loki.sysctl.io
|
|
|
|
10.100.0.2 telegraf.sysctl.io
|
|
|
|
10.100.0.2 headscale.sysctl.io
|
2023-12-11 13:07:16 +01:00
|
|
|
'';
|
|
|
|
|
2023-12-05 05:27:06 +01:00
|
|
|
networking.firewall.allowedUDPPorts = [ 51820 ];
|
|
|
|
networking.firewall.interfaces.wireguard0.allowedTCPPorts = [ 22 ];
|
|
|
|
|
|
|
|
# Set up the secrets file:
|
2024-01-12 09:23:27 +01:00
|
|
|
sops.secrets."wireguard_key" = {
|
2023-12-05 05:27:06 +01:00
|
|
|
owner = "root";
|
2024-01-12 09:23:27 +01:00
|
|
|
sopsFile = ../../../secrets/hosts/osaka-linode-01.yaml;
|
2023-12-05 05:27:06 +01:00
|
|
|
};
|
|
|
|
|
2024-01-12 09:23:27 +01:00
|
|
|
sops.secrets."preshared_key" = {
|
2023-12-05 05:27:06 +01:00
|
|
|
owner = "root";
|
|
|
|
sopsFile = ../../../secrets/wireguard.yaml;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Wireguard Forwarder
|
|
|
|
boot.kernel.sysctl = {
|
|
|
|
"net.ipv4.ip_forward" = true;
|
|
|
|
"net.ipv4.conf.all.forwarding" = 1;
|
|
|
|
"net.ipv4.conf.default.forwarding" = 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.wireguard = {
|
|
|
|
enable = true;
|
|
|
|
interfaces = {
|
|
|
|
"wireguard0" = {
|
|
|
|
ips = [ "10.100.0.1/24" ];
|
|
|
|
listenPort = 51820;
|
2024-01-12 09:23:27 +01:00
|
|
|
privateKeyFile = "/run/secrets/wireguard_key";
|
2023-12-06 10:00:28 +01:00
|
|
|
postSetup = ''${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -o enp0s4 -j MASQUERADE'';
|
|
|
|
postShutdown = ''${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.100.0.0/24 -o enp0s4 -j MASQUERADE'';
|
2023-12-05 05:27:06 +01:00
|
|
|
peers = [
|
2024-01-29 03:39:49 +01:00
|
|
|
{ # framework-server
|
2023-12-05 05:27:06 +01:00
|
|
|
publicKey = "trHvfNtQ7HKMiJjxEXo2Iubq5G6egjx7gHiBlDmJ5Ek=";
|
2024-01-12 09:23:27 +01:00
|
|
|
presharedKeyFile = "/run/secrets/preshared_key";
|
2023-12-05 05:27:06 +01:00
|
|
|
persistentKeepalive = 5;
|
|
|
|
allowedIPs = [ "10.100.0.2/32" ];
|
|
|
|
}
|
2024-01-29 03:39:49 +01:00
|
|
|
{ # backups-rpi4
|
2024-01-29 08:30:25 +01:00
|
|
|
publicKey = "cqocpMyY8Z0Jl0hoAdghn3dR3VhkkOYyeSwW6UKk9Fs=";
|
2024-01-29 03:39:49 +01:00
|
|
|
presharedKeyFile = "/run/secrets/preshared_key";
|
|
|
|
persistentKeepalive = 5;
|
|
|
|
allowedIPs = [ "10.100.0.3/32" ];
|
|
|
|
}
|
2023-12-05 05:27:06 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-03-25 01:46:12 +01:00
|
|
|
}
|