mirror of
https://github.com/starr-dusT/dotfiles.git
synced 2025-02-19 19:27:31 -08:00
Add wireguard client to Kestrel
This commit is contained in:
parent
38a7e3c2a3
commit
afc18704d0
1
home/private_dot_wireguard/kestrel.pub
Normal file
1
home/private_dot_wireguard/kestrel.pub
Normal file
@ -0,0 +1 @@
|
|||||||
|
hPso657fppLYvBU31Rtqqg792JEoPv7r82JgLoF8S2Y=
|
1
home/private_dot_wireguard/kestrel.tmpl
Normal file
1
home/private_dot_wireguard/kestrel.tmpl
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ (secret "Wireguard - Kestrel Secret" "NOTES") }}
|
@ -1,5 +1,10 @@
|
|||||||
{ config, pkgs, user, lib, ... }:
|
{ config, pkgs, user, lib, ... }:
|
||||||
{
|
{
|
||||||
|
imports = [
|
||||||
|
./wireguard-client.nix
|
||||||
|
../../modules
|
||||||
|
];
|
||||||
|
|
||||||
nix = {
|
nix = {
|
||||||
package = pkgs.nixFlakes;
|
package = pkgs.nixFlakes;
|
||||||
extraOptions = "experimental-features = nix-command flakes";
|
extraOptions = "experimental-features = nix-command flakes";
|
||||||
@ -32,7 +37,6 @@
|
|||||||
|
|
||||||
# Set networking options
|
# Set networking options
|
||||||
networking.hostName = "kestrel";
|
networking.hostName = "kestrel";
|
||||||
networking.networkmanager.enable = true;
|
|
||||||
networking.firewall.checkReversePath = "loose";
|
networking.firewall.checkReversePath = "loose";
|
||||||
networking.firewall.enable = false;
|
networking.firewall.enable = false;
|
||||||
|
|
||||||
@ -63,7 +67,6 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
# Enable modules
|
# Enable modules
|
||||||
imports = [ ../../modules ];
|
|
||||||
modules = {
|
modules = {
|
||||||
desktop = {
|
desktop = {
|
||||||
sway.enable = true;
|
sway.enable = true;
|
||||||
|
42
provision/nixos/hosts/kestrel/wireguard-client.nix
Normal file
42
provision/nixos/hosts/kestrel/wireguard-client.nix
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{ config, pkgs, user, lib, ... }:
|
||||||
|
{
|
||||||
|
networking.firewall = {
|
||||||
|
allowedUDPPorts = [ 51820 ]; # Clients and peers can use the same port, see listenport
|
||||||
|
};
|
||||||
|
# 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 = [ "192.168.2.3/32" ];
|
||||||
|
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/${user}/.wireguard/kestrel";
|
||||||
|
|
||||||
|
peers = [
|
||||||
|
# For a client configuration, one peer entry for the server will suffice.
|
||||||
|
|
||||||
|
{
|
||||||
|
# Public key of the server (not a file path).
|
||||||
|
publicKey = "bd7bbZOngl/FTdBlnbIhgCLNf6yx5X8WjiRB7E1NEQQ=";
|
||||||
|
|
||||||
|
# Forward all the traffic via VPN.
|
||||||
|
allowedIPs = [ "0.0.0.0/0" "::/0" ];
|
||||||
|
# Or forward only particular subnets
|
||||||
|
#allowedIPs = [ "10.100.0.1" "91.108.12.0/22" ];
|
||||||
|
|
||||||
|
# Set this to the server IP and port.
|
||||||
|
endpoint = "192.168.1.175: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;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
@ -45,6 +45,11 @@
|
|||||||
publicKey = "r2/IeYCO1T+l248387wUBoNnc2DK9O8pHcIr/NQqezM=";
|
publicKey = "r2/IeYCO1T+l248387wUBoNnc2DK9O8pHcIr/NQqezM=";
|
||||||
allowedIPs = [ "192.168.2.2/32" ];
|
allowedIPs = [ "192.168.2.2/32" ];
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
# Kestrel
|
||||||
|
publicKey = "hPso657fppLYvBU31Rtqqg792JEoPv7r82JgLoF8S2Y=";
|
||||||
|
allowedIPs = [ "192.168.2.3/32" ];
|
||||||
|
}
|
||||||
# More peers can be added here.
|
# More peers can be added here.
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user