94 lines
3.1 KiB
Nix
94 lines
3.1 KiB
Nix
{
|
|
config,
|
|
pkgs,
|
|
...
|
|
}: {
|
|
systemd.services.wireguard-wg0.serviceConfig.Restart = "on-failure";
|
|
systemd.services.wireguard-wg0.serviceConfig.RestartSec = "5s";
|
|
systemd.services.wireguard-wg1.serviceConfig.Restart = "on-failure";
|
|
systemd.services.wireguard-wg1.serviceConfig.RestartSec = "5s";
|
|
|
|
# Enable WireGuard
|
|
networking.wireguard.interfaces = {
|
|
# "wg0" is the network interface name. You can name the interface arbitrarily.
|
|
wg0 = {
|
|
# Determines the IP address and subnet of the client's end of the tunnel interface.
|
|
ips = [
|
|
"10.0.0.13/32"
|
|
"fc00:200::13/128"
|
|
];
|
|
listenPort = 51820; # to match firewall allowedUDPPorts (without this wg uses random port numbers)
|
|
|
|
# Path to the private key file.
|
|
#
|
|
# 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
|
|
# recommended.
|
|
privateKeyFile = "/home/hensoko/.config/wireguard/hosting-de.private";
|
|
|
|
peers = [
|
|
# For a client configuration, one peer entry for the server will suffice.
|
|
|
|
{
|
|
# Public key of the server (not a file path).
|
|
publicKey = "02/MRPduMGx1as7yS4G7GpL4+pQjsjpyS/tD9iPu8X0=";
|
|
|
|
# Forward all the traffic via VPN.
|
|
allowedIPs = [
|
|
"10.0.0.0/24"
|
|
"192.168.50.0/24"
|
|
"192.168.200.0/24"
|
|
"10.20.30.0/24"
|
|
"10.20.50.0/24"
|
|
"fc00:200::/120"
|
|
"95.129.51.5"
|
|
"95.129.54.43"
|
|
"134.0.28.89"
|
|
"134.0.27.108"
|
|
"134.0.25.181"
|
|
];
|
|
|
|
# Set this to the server IP and port.
|
|
endpoint = "134.0.30.154:51820"; # ToDo: route to endpoint not automatically configured https://wiki.archlinux.org/index.php/WireGuard#Loop_routing https://discourse.nixos.org/t/solved-minimal-firewall-setup-for-wireguard-client/7577
|
|
|
|
# Send keepalives every 25 seconds. Important to keep NAT tables alive.
|
|
persistentKeepalive = 25;
|
|
}
|
|
];
|
|
};
|
|
wg1 = {
|
|
# Determines the IP address and subnet of the client's end of the tunnel interface.
|
|
ips = [
|
|
"10.0.1.121"
|
|
];
|
|
listenPort = 51821; # to match firewall allowedUDPPorts (without this wg uses random port numbers)
|
|
|
|
# Path to the private key file.
|
|
#
|
|
# 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
|
|
# recommended.
|
|
privateKeyFile = "/home/hensoko/.config/wireguard/data-gssws-de.private";
|
|
|
|
peers = [
|
|
# For a client configuration, one peer entry for the server will suffice.
|
|
|
|
{
|
|
# Public key of the server (not a file path).
|
|
publicKey = "t1DS0y6eVzyGwomKAEWTWVsHK3xB7M/fNQ3wLgE3+B8=";
|
|
|
|
allowedIPs = [
|
|
"10.0.1.0/24"
|
|
];
|
|
|
|
# Set this to the server IP and port.
|
|
endpoint = "vpn.gssws.de:51899";
|
|
|
|
# Send keepalives every 25 seconds. Important to keep NAT tables alive.
|
|
persistentKeepalive = 25;
|
|
}
|
|
];
|
|
};
|
|
};
|
|
}
|