enable wireguard
This commit is contained in:
parent
cac62944b3
commit
7a31488abd
@ -1,4 +1,4 @@
|
|||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
{
|
{
|
||||||
imports = [ ./configuration.nix ./mailserver.nix ./roundcube.nix ./postgres.nix ];
|
imports = [ ./configuration.nix ./mailserver.nix ./roundcube.nix ./postgres.nix ./wireguard.nix ];
|
||||||
}
|
}
|
||||||
|
34
mailserver/wireguard.nix
Normal file
34
mailserver/wireguard.nix
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{ pkgs, ... }: {
|
||||||
|
networking = {
|
||||||
|
nat = {
|
||||||
|
enable = true;
|
||||||
|
externalInterface = "eth0";
|
||||||
|
internalInterfaces = [ "wg0" ];
|
||||||
|
};
|
||||||
|
firewall = {
|
||||||
|
allowedUDPPorts = [ 51820 ];
|
||||||
|
};
|
||||||
|
wireguard.interfaces = {
|
||||||
|
wg0 = {
|
||||||
|
ips = [ "10.100.0.1/24" ];
|
||||||
|
listenPort = 51820;
|
||||||
|
postSetup = ''
|
||||||
|
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -o eth0 -j MASQUERADE
|
||||||
|
'';
|
||||||
|
postShutdown = ''
|
||||||
|
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.100.0.0/24 -o eth0 -j MASQUERADE
|
||||||
|
'';
|
||||||
|
privateKeyFile = "/etc/wireguard/privatekey";
|
||||||
|
generatePrivateKeyFile = true;
|
||||||
|
peers = [
|
||||||
|
{
|
||||||
|
publicKey = "28yXYLk4U0r6MdWFEZzk6apI8uhg962wMprF47wUJyI=";
|
||||||
|
allowedIPs = [ "10.100.0.2/32" ];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user