From 448e4dfda83b3e2d287ec60910e049a75f894a4e Mon Sep 17 00:00:00 2001 From: coolneng Date: Fri, 12 Mar 2021 12:08:22 +0100 Subject: [PATCH] Add Wireguard configuration --- modules/networking.nix | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/modules/networking.nix b/modules/networking.nix index 46505be..754368a 100644 --- a/modules/networking.nix +++ b/modules/networking.nix @@ -43,8 +43,32 @@ 1194 # Wireguard ]; extraCommands = '' - iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE + iptables -t nat -A POSTROUTING -s 10.9.0.0/24 -o eth0 -j MASQUERADE ''; }; + # Enable NAT for wireguard + networking.nat = { + enable = true; + externalInterface = "eth0"; + internalInterfaces = [ "wg0" ]; + }; + + # Wireguard setup + networking.wireguard.interfaces = { + wg0 = { + ips = [ "10.9.0.1/24" ]; + listenPort = 1194; + privateKeyFile = "/home/coace/.wg/keys/privatekey"; + peers = [ + # Fernando + { + # Placeholder public key + publicKey = "XMkTztU2Y8hw6Fu/2o4Gszij+EmNacvFMXuZyHS1n38="; + allowedIPs = [ "10.9.0.2/32" ]; + } + ]; + }; + }; + }