mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-25 06:19:00 +00:00
hosts/ni: change Wireguard setup to wg-quick
This commit is contained in:
parent
86afc41f28
commit
d12f1ea15f
@ -195,57 +195,24 @@ in
|
|||||||
# Setting up Wireguard as a VPN tunnel. Since this is a laptop that meant to
|
# Setting up Wireguard as a VPN tunnel. Since this is a laptop that meant to
|
||||||
# be used anywhere, we're configuring Wireguard here as a "client".
|
# be used anywhere, we're configuring Wireguard here as a "client".
|
||||||
#
|
#
|
||||||
# We're also setting up this configuration as a forwarder
|
# We're using wg-quick here as this host is using network managers that can
|
||||||
systemd.network = {
|
# differ between workflows (i.e., GNOME and KDE Plasma using NetworkManager,
|
||||||
netdevs."99-${wireguardIFName}" = {
|
# something else using systemd-networkd).
|
||||||
netdevConfig = {
|
networking.wg-quick.interfaces.wireguard0 = {
|
||||||
Description = "Plover - internal";
|
privateKeyFile = config.sops.secrets."ni/wireguard/private-key".path;
|
||||||
Name = wireguardIFName;
|
|
||||||
Kind = "wireguard";
|
|
||||||
};
|
|
||||||
|
|
||||||
wireguardConfig = {
|
address = with wireguardPeers.desktop; [
|
||||||
PrivateKeyFile = config.sops.secrets."ni/wireguard/private-key".path;
|
"${IPv4}/32"
|
||||||
ListenPort = wireguardPort;
|
"${IPv6}/128"
|
||||||
};
|
];
|
||||||
|
|
||||||
wireguardPeers = [
|
peers = [
|
||||||
# Plover server peer. This is the main "server" of the network.
|
{
|
||||||
{
|
publicKey = lib.readFile ../plover/files/wireguard/wireguard-public-key-plover;
|
||||||
wireguardPeerConfig = {
|
presharedKeyFile = config.sops.secrets."ni/wireguard/preshared-keys/plover".path;
|
||||||
PublicKey = lib.readFile ../plover/files/wireguard/wireguard-public-key-plover;
|
allowedIPs = wireguardAllowedIPs;
|
||||||
PresharedKeyFile = config.sops.secrets."ni/wireguard/preshared-keys/plover".path;
|
endpoint = "${interfaces.main'.IPv4.address}:${toString wireguardPort}";
|
||||||
AllowedIPs = lib.concatStringsSep "," wireguardAllowedIPs;
|
}
|
||||||
Endpoint = "${interfaces.main'.IPv4.address}:${toString wireguardPort}";
|
];
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
networks."99-${wireguardIFName}" = {
|
|
||||||
matchConfig.Name = wireguardIFName;
|
|
||||||
address = with wireguardPeers.desktop; [
|
|
||||||
"${IPv4}/32"
|
|
||||||
"${IPv6}/128"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Otherwise, it will autostart every bootup when I need it only at few
|
|
||||||
# hours at a time.
|
|
||||||
linkConfig.ActivationPolicy = "manual";
|
|
||||||
|
|
||||||
routes = [
|
|
||||||
{
|
|
||||||
routeConfig = {
|
|
||||||
Gateway = wireguardPeers.server.IPv4;
|
|
||||||
Destination = let
|
|
||||||
ip = lib.strings.splitString "." wireguardPeers.server.IPv4;
|
|
||||||
properRange = lib.lists.take 3 ip ++ [ "0" ];
|
|
||||||
ip' = lib.concatStringsSep "." properRange;
|
|
||||||
in "${ip'}/16";
|
|
||||||
GatewayOnLink = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user