almost working wireguard

This commit is contained in:
Sky Hearn 2024-03-07 02:41:55 +00:00
parent fef06f7eae
commit 42768ab36e
1 changed files with 5 additions and 5 deletions

View File

@ -31,7 +31,7 @@
# wireguard server setup # wireguard server setup
# enable NAT # enable NAT
networking.nat.enable = true; networking.nat.enable = true;
networking.nat.externalInterface = "eth0"; networking.nat.externalInterface = "eno4";
networking.nat.internalInterfaces = [ "wg0" ]; networking.nat.internalInterfaces = [ "wg0" ];
networking.firewall = { networking.firewall = {
allowedUDPPorts = [ 51820 ]; allowedUDPPorts = [ 51820 ];
@ -49,12 +49,12 @@
# This allows the wireguard server to route your traffic to the internet and hence be like a VPN # This allows the wireguard server to route your traffic to the internet and hence be like a VPN
# For this to work you have to set the dnsserver IP of your router (or dnsserver of choice) in your clients # For this to work you have to set the dnsserver IP of your router (or dnsserver of choice) in your clients
postSetup = '' postSetup = ''
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -o eth0 -j MASQUERADE ${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -o eno4 -j MASQUERADE
''; '';
# This undoes the above command # This undoes the above command
postShutdown = '' postShutdown = ''
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.100.0.0/24 -o eth0 -j MASQUERADE ${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.100.0.0/24 -o eno4 -j MASQUERADE
''; '';
# Path to the private key file. # Path to the private key file.
@ -62,7 +62,7 @@
# Note: The private key can also be included inline via the privateKey option, # Note: The private key can also be included inline via the privateKey option,
# but this makes the private key world-readable; thus, using privateKeyFile is # but this makes the private key world-readable; thus, using privateKeyFile is
# recommended. # recommended.
privateKeyFile = "path to private key file"; privateKeyFile = "/run/keys/wg-privatekey"; # TODO: Change this to be a sops secret
peers = [ peers = [
# List of allowed peers. # List of allowed peers.
@ -77,7 +77,7 @@
allowedIPs = [ "10.100.0.3/32" ]; allowedIPs = [ "10.100.0.3/32" ];
} }
{ # skyLaptop { # skyLaptop
publicKey = "L4msD0mEG2ctKDtaMJW2y3cs1fT2LBRVV7iVlWZ2nZc="; publicKey = "2sg0sgMMGQrCGt0f/5+1kO/B0Ghfb137DTf9nYctZTM=";
allowedIPs = [ "10.100.0.4/32" ]; allowedIPs = [ "10.100.0.4/32" ];
} }
{ # skyDesktop { # skyDesktop