add wireguard hub and spoke setup
This commit is contained in:
parent
68b0e6dda1
commit
2567f78054
7 changed files with 108 additions and 4 deletions
|
@ -936,11 +936,11 @@
|
||||||
"secrets": {
|
"secrets": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1666166753,
|
"lastModified": 1674110639,
|
||||||
"narHash": "sha256-Gev83ZYEkEEXKcz+ChNajNzzuqPodjVbSlgdHLHXtVs=",
|
"narHash": "sha256-IpvJcMtRxcUM4gk8Ha0yKsIJs7Dmo+r9XBb8wUM2sDo=",
|
||||||
"ref": "main",
|
"ref": "main",
|
||||||
"rev": "c5c4fad9987a0aaab4d2b072fe40ec55f15462d2",
|
"rev": "ef5f10f16f670e26c950bacf95d3d0ec90f0a371",
|
||||||
"revCount": 39,
|
"revCount": 40,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "ssh://gitea@git.ingolf-wagner.de/palo/nixos-secrets.git"
|
"url": "ssh://gitea@git.ingolf-wagner.de/palo/nixos-secrets.git"
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
./taskwarrior-pushover.nix
|
./taskwarrior-pushover.nix
|
||||||
#./neo4j.nix
|
#./neo4j.nix
|
||||||
./jellyfin.nix
|
./jellyfin.nix
|
||||||
|
./wireguard.nix
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
30
nixos/machines/pepe/wireguard.nix
Normal file
30
nixos/machines/pepe/wireguard.nix
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{ pkgs, config, ... }:
|
||||||
|
{
|
||||||
|
networking.firewall.trustedInterfaces = [ "wg0" ];
|
||||||
|
networking.firewall.allowedUDPPorts = [ 51820 ];
|
||||||
|
sops.secrets.wireguard_private = { };
|
||||||
|
|
||||||
|
|
||||||
|
# Enable WireGuard
|
||||||
|
networking.wg-quick.interfaces = {
|
||||||
|
# Hub and Spoke Setup
|
||||||
|
# https://www.procustodibus.com/blog/2020/11/wireguard-hub-and-spoke-config/
|
||||||
|
wg0 = {
|
||||||
|
address = [ "10.100.0.2/32" ];
|
||||||
|
listenPort = 51820; # to match firewall allowedUDPPorts (without this wg uses random port numbers)
|
||||||
|
privateKeyFile = config.sops.secrets.wireguard_private.path;
|
||||||
|
mtu = 1280;
|
||||||
|
|
||||||
|
# server
|
||||||
|
peers = [
|
||||||
|
{
|
||||||
|
# robi
|
||||||
|
publicKey = "uWR93xJe5oEbX3DsAYpOS9CuSg1VmXEQxJzdlJpe3DU=";
|
||||||
|
allowedIPs = [ "10.100.0.1/24" ];
|
||||||
|
endpoint = "ingolf-wagner.de:51820";
|
||||||
|
persistentKeepalive = 25;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -27,6 +27,7 @@
|
||||||
./transmission2.nix
|
./transmission2.nix
|
||||||
./vaultwarden.nix
|
./vaultwarden.nix
|
||||||
./nginx.nix
|
./nginx.nix
|
||||||
|
./wireguard.nix
|
||||||
|
|
||||||
|
|
||||||
#../../system/server
|
#../../system/server
|
||||||
|
|
45
nixos/machines/robi/wireguard.nix
Normal file
45
nixos/machines/robi/wireguard.nix
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
{ pkgs, config, ... }:
|
||||||
|
{
|
||||||
|
networking.firewall.trustedInterfaces = [ "wg0" ];
|
||||||
|
networking.firewall.allowedUDPPorts = [ 51820 ];
|
||||||
|
sops.secrets.wireguard_private = { };
|
||||||
|
boot.kernel.sysctl."net.ipv4.ip_forward" = true;
|
||||||
|
|
||||||
|
# Enable WireGuard
|
||||||
|
networking.wg-quick.interfaces = {
|
||||||
|
# Hub and Spoke Setup
|
||||||
|
# https://www.procustodibus.com/blog/2020/11/wireguard-hub-and-spoke-config/
|
||||||
|
wg0 = {
|
||||||
|
address = [ "10.100.0.1/32" ];
|
||||||
|
listenPort = 51820; # to match firewall allowedUDPPorts (without this wg uses random port numbers)
|
||||||
|
privateKeyFile = config.sops.secrets.wireguard_private.path;
|
||||||
|
mtu = 1280;
|
||||||
|
|
||||||
|
postUp = ''
|
||||||
|
${pkgs.iptables}/bin/iptables -A FORWARD -i wg0 -j ACCEPT
|
||||||
|
'';
|
||||||
|
postDown = ''
|
||||||
|
${pkgs.iptables}/bin/iptables -D FORWARD -i wg0 -j ACCEPT
|
||||||
|
'';
|
||||||
|
|
||||||
|
# clients
|
||||||
|
peers = [
|
||||||
|
{
|
||||||
|
# pepe
|
||||||
|
publicKey = "wb54y/fG8ocSH9QrDmfajez/fUcJBZK369xLu37XBHk=";
|
||||||
|
allowedIPs = [ "10.100.0.2/32" ];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
# sterni
|
||||||
|
publicKey = "SdMRgC5IM7dywzZxLAHm45cpj9J3IENTMClZm1BxbV4=";
|
||||||
|
allowedIPs = [ "10.100.0.3/32" ];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
# iphone
|
||||||
|
publicKey = "XPVzH+wBLsqukTHHjngkGJhYN0nRdQ7esadiimMJQnI=";
|
||||||
|
allowedIPs = [ "10.100.0.4/32" ];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -14,6 +14,7 @@
|
||||||
#./wireshark.nix
|
#./wireshark.nix
|
||||||
./scanner.nix
|
./scanner.nix
|
||||||
./qemu.nix
|
./qemu.nix
|
||||||
|
./wireguard.nix
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
26
nixos/machines/sterni/wireguard.nix
Normal file
26
nixos/machines/sterni/wireguard.nix
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
networking.firewall.allowedUDPPorts = [ 51820 ];
|
||||||
|
sops.secrets.wireguard_private = { };
|
||||||
|
|
||||||
|
# Enable WireGuard
|
||||||
|
networking.wg-quick.interfaces = {
|
||||||
|
# Hub and Spoke Setup
|
||||||
|
# https://www.procustodibus.com/blog/2020/11/wireguard-hub-and-spoke-config/
|
||||||
|
wg0 = {
|
||||||
|
address = [ "10.100.0.3/32" ];
|
||||||
|
listenPort = 51820; # to match firewall allowedUDPPorts (without this wg uses random port numbers)
|
||||||
|
privateKeyFile = config.sops.secrets.wireguard_private.path;
|
||||||
|
mtu = 1280;
|
||||||
|
|
||||||
|
peers = [
|
||||||
|
{
|
||||||
|
# robi
|
||||||
|
publicKey = "uWR93xJe5oEbX3DsAYpOS9CuSg1VmXEQxJzdlJpe3DU=";
|
||||||
|
allowedIPs = [ "10.100.0.1/24" ];
|
||||||
|
endpoint = "ingolf-wagner.de:51820";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue