This commit is contained in:
iFargle 2023-10-08 16:23:06 +09:00
parent 13c90925e2
commit 77e8b193f0

View file

@ -45,8 +45,16 @@
ips = [ "10.100.0.1/24" ]; ips = [ "10.100.0.1/24" ];
listenPort = 51820; listenPort = 51820;
privateKeyFile = "/run/secrets/wireguard_keys/osaka-vultr-01"; privateKeyFile = "/run/secrets/wireguard_keys/osaka-vultr-01";
postSetup = ''${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -o eno3 -j MASQUERADE''; postSetup = ''
postShutdown = ''${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.100.0.0/24 -o eno3 -j MASQUERADE''; ${pkgs.iptables}/bin/iptables -A FORWARD -i wireguard0 -j ACCEPT
${pkgs.iptables}/bin/iptables -A FORWARD -o wireguard0 -j ACCEPT
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -o eno3 -j MASQUERADE
'';
postShutdown = ''
${pkgs.iptables}/bin/iptables -D FORWARD -i wireguard0 -j ACCEPT
${pkgs.iptables}/bin/iptables -D FORWARD -o wireguard0 -j ACCEPT
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.100.0.0/24 -o eno3 -j MASQUERADE
'';
peers = [ peers = [
{ # nixos-rpi4-03 { # nixos-rpi4-03
publicKey = "trHvfNtQ7HKMiJjxEXo2Iubq5G6egjx7gHiBlDmJ5Ek="; publicKey = "trHvfNtQ7HKMiJjxEXo2Iubq5G6egjx7gHiBlDmJ5Ek=";
@ -59,10 +67,6 @@
}; };
}; };
networking.firewall.extraCommands = "
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -d 10.100.0.2 -p tcp -m tcp --dport 80 -j MASQUERADE
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -d 10.100.0.2 -p tcp -m tcp --dport 443 -j MASQUERADE
";
networking.nat = { networking.nat = {
enable = true; enable = true;
internalInterfaces = [ "wireguard0" ]; internalInterfaces = [ "wireguard0" ];