nix-config/hosts/cirrus/wireguard-server.nix

124 lines
3.4 KiB
Nix
Raw Normal View History

2022-06-18 11:49:27 +02:00
{ config, ... }:
{
2023-01-30 23:30:48 +01:00
networking.firewall = {
allowedUDPPorts = [
# wireguards
51820
51821
2023-06-16 13:33:20 +02:00
34197
2023-01-30 23:30:48 +01:00
];
allowedTCPPorts = [
# port forward ssh to music
2020
];
# port-forward ssh to the music machine
extraCommands = ''
iptables -t nat -I PREROUTING -p tcp --dport 2020 -j DNAT --to-destination 10.34.45.101:22
2023-06-16 13:33:20 +02:00
iptables -t nat -I PREROUTING -p udp --dport 34197 -j DNAT --to-destination 10.34.45.111:34197
2023-02-08 16:38:58 +01:00
iptables ! -o lo -t nat -A POSTROUTING -j MASQUERADE
2023-01-30 23:30:48 +01:00
'';
extraStopCommands = ''
iptables -t nat -D PREROUTING -p tcp --dport 2020 -j DNAT --to-destination 10.34.45.101:22 || true
2023-06-16 13:33:20 +02:00
iptables -t nat -D PREROUTING -p udp --dport 34197 -j DNAT --to-destination 10.34.45.111:34197 || true
2023-01-30 23:30:48 +01:00
'';
};
2022-06-18 11:57:32 +02:00
networking.wireguard.enable = true;
2023-01-30 23:30:48 +01:00
2022-06-18 11:49:27 +02:00
systemd.network = {
2022-06-19 22:09:13 +02:00
# oxalab
2022-06-18 11:49:27 +02:00
netdevs."oxalab" = {
netdevConfig = {
Kind = "wireguard";
Name = "oxalab";
Description = "oxa's enterprise network";
};
wireguardConfig = {
PrivateKeyFile = config.sops.secrets."wg/oxalab-seckey".path;
ListenPort = 51820;
# own pubkey: 5nCVC21BL+1r70OGwA4Q6Z/gcPLC3+ZF8sTurdn7N0E=
};
wireguardPeers = [
{
# microwave
2022-06-18 11:49:27 +02:00
wireguardPeerConfig = {
2022-06-26 21:19:15 +02:00
PublicKey = "0zpfcNrmbsNwwbnDDX4SMl4BVTB0zuhGKixT9TJQoHc=";
AllowedIPs = [ "10.66.66.10/32" ];
PersistentKeepalive = 25;
};
2022-06-18 11:49:27 +02:00
}
{
# Dishwasher
wireguardPeerConfig = {
2022-06-26 21:19:15 +02:00
PublicKey = "AdWUBbyeRkxdP9HUu25PpISoxbgQ8oeCw3BmV93xtAw=";
AllowedIPs = [ "10.66.66.100/32" ];
PersistentKeepalive = 25;
};
2022-06-18 11:49:27 +02:00
}
];
};
networks."oxalab" = {
matchConfig.Name = "oxalab";
networkConfig = {
2022-06-18 17:09:07 +02:00
Address = "10.66.66.1/24";
2022-06-18 17:24:09 +02:00
IPForward = "ipv4";
2022-06-18 11:49:27 +02:00
};
};
2022-06-19 22:09:13 +02:00
# oxaproxy
netdevs."oxaproxy" = {
netdevConfig = {
Kind = "wireguard";
Name = "oxaproxy";
Description = "oxa's enterprise reverse-proxy network";
};
wireguardConfig = {
PrivateKeyFile = config.sops.secrets."wg/oxaproxy-seckey".path;
#own pubkey 0KMtL2fQOrrCH6c2a2l4FKiM73G86sUuyaNj4FarzVM=
ListenPort = 51821;
};
2022-06-26 21:06:43 +02:00
wireguardPeers = [
# nextcloud
{
2022-06-26 21:19:15 +02:00
wireguardPeerConfig = {
PublicKey = "KCYoGx7TGei4X79EZo2NONCcmQjPzBUN1Ds6I9lQbz0=";
AllowedIPs = [ "10.34.45.100/32" ];
PersistentKeepalive = 25;
};
}
2023-01-24 20:40:41 +01:00
# music
{
wireguardPeerConfig = {
PublicKey = "vQNkp51S9qLsu97dLPj0/EqFwvVtRFZpMHufgKhxum0=";
AllowedIPs = [ "10.34.45.101/32" ];
PersistentKeepalive = 25;
};
}
2023-05-15 16:50:29 +02:00
# news
{
wireguardPeerConfig = {
PublicKey = "guzNmsPcQw4EGSLU3X0SP+WPKAcoMc+xv9SLWdHV1V0=";
AllowedIPs = [ "10.34.45.102/32" ];
PersistentKeepalive = 25;
};
}
2023-06-16 13:33:20 +02:00
{
wireguardPeerConfig = {
PublicKey = "6rwSThPEfTyYvMVSnHNcNPRntCHEQFyscF2SodI8A34=";
AllowedIPs = [ "10.34.45.111/32" ];
PersistentKeepalive = 25;
};
}
2022-06-26 21:06:43 +02:00
];
2022-06-19 22:09:13 +02:00
};
networks."oxaproxy" = {
matchConfig.Name = "oxaproxy";
networkConfig = {
Address = "10.34.45.1/24";
};
};
2022-06-18 11:49:27 +02:00
};
}