2025-05-24 23:03:40 -04:00
{ config , lib , pkgs , . . . }:
2025-05-22 13:18:59 -04:00
{
# Enable WireGuard
networking . wireguard . enable = true ;
networking . wireguard . interfaces = {
# "wg0" is the network interface name. You can name the interface arbitrarily.
tr = {
# Determines the IP address and subnet of the client's end of the tunnel interface.
ips = [ " 1 0 . 0 . 1 . 2 / 2 4 " ] ;
#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 = " / r o o t / w i r e g u a r d - k e y s / p r i v a t e " ;
peers = [
# For a client configuration, one peer entry for the server will suffice.
{
# Public key of the server (not a file path).
publicKey = " T S P q 7 s J b Y 9 D N h C u 7 6 s c 0 s 9 w t F n f H h k / u d 0 D / J i E P f V 4 = " ;
# Forward all the traffic via VPN.
allowedIPs = [ " 1 0 . 0 . 1 . 1 " ] ;
# Or forward only particular subnets
#allowedIPs = [ "10.100.0.1" "91.108.12.0/22" ];
# Set this to the server IP and port.
endpoint = " 7 9 . 7 2 . 3 0 . 1 2 6 : 5 1 8 2 1 " ; # 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 ;
}
] ;
} ;
} ;
}