2022-08-21 22:53:04 +00:00
{
2023-02-25 13:45:21 +00:00
config ,
pkgs ,
. . .
} : {
2022-08-21 22:53:04 +00:00
systemd . services . wireguard-wg0 . serviceConfig . Restart = " o n - f a i l u r e " ;
systemd . services . wireguard-wg0 . serviceConfig . RestartSec = " 5 s " ;
systemd . services . wireguard-wg1 . serviceConfig . Restart = " o n - f a i l u r e " ;
systemd . services . wireguard-wg1 . serviceConfig . RestartSec = " 5 s " ;
# 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 = [
" 1 0 . 0 . 0 . 1 3 / 3 2 "
" f c 0 0 : 2 0 0 : : 1 3 / 1 2 8 "
] ;
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 = " / h o m e / h e n s o k o / . c o n f i g / w i r e g u a r d / h o s t i n g - d e . 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 = " 0 2 / M R P d u M G x 1 a s 7 y S 4 G 7 G p L 4 + p Q j s j p y S / t D 9 i P u 8 X 0 = " ;
# Forward all the traffic via VPN.
allowedIPs = [
" 1 0 . 0 . 0 . 0 / 2 4 "
" 1 9 2 . 1 6 8 . 5 0 . 0 / 2 4 "
" 1 9 2 . 1 6 8 . 2 0 0 . 0 / 2 4 "
" 1 0 . 2 0 . 3 0 . 0 / 2 4 "
" 1 0 . 2 0 . 5 0 . 0 / 2 4 "
" f c 0 0 : 2 0 0 : : / 1 2 0 "
" 9 5 . 1 2 9 . 5 1 . 5 "
" 9 5 . 1 2 9 . 5 4 . 4 3 "
" 1 3 4 . 0 . 2 8 . 8 9 "
" 1 3 4 . 0 . 2 7 . 1 0 8 "
" 1 3 4 . 0 . 2 5 . 1 8 1 "
] ;
# Set this to the server IP and port.
endpoint = " 1 3 4 . 0 . 3 0 . 1 5 4 : 5 1 8 2 0 " ; # 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 = [
2023-03-07 15:48:46 +00:00
" 1 0 . 0 . 1 . 1 2 1 "
2022-08-21 22:53:04 +00:00
] ;
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 = " / h o m e / h e n s o k o / . c o n f i g / w i r e g u a r d / d a t a - g s s w s - d e . 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).
2023-02-25 13:45:21 +00:00
publicKey = " t 1 D S 0 y 6 e V z y G w o m K A E W T W V s H K 3 x B 7 M / f N Q 3 w L g E 3 + B 8 = " ;
2022-08-21 22:53:04 +00:00
allowedIPs = [
2023-03-07 15:48:46 +00:00
" 1 0 . 0 . 1 . 0 / 2 4 "
2022-08-21 22:53:04 +00:00
] ;
# Set this to the server IP and port.
2023-03-07 15:48:46 +00:00
endpoint = " v p n . g s s w s . d e : 5 1 8 9 9 " ;
2022-08-21 22:53:04 +00:00
# Send keepalives every 25 seconds. Important to keep NAT tables alive.
persistentKeepalive = 25 ;
}
] ;
} ;
} ;
}