Update Wireguard client also
This commit is contained in:
parent
08827b5d5d
commit
48a2e3211d
12 changed files with 128 additions and 110 deletions
|
@ -1,14 +0,0 @@
|
|||
{ config, lib, ... }:
|
||||
{
|
||||
networking.wg-quick.interfaces.wgc = lib.mkIf config.services.wireguard.client.enable {
|
||||
privateKey = config.secrets.wg.clientKey;
|
||||
peers = [
|
||||
{ # Home server
|
||||
publicKey = "qnOT/lXOJMaQgDUdXpyfGZB2IEyUouRje2m/bCe9ux8=";
|
||||
allowedIPs = [ "11.0.0.0/8" ];
|
||||
endpoint = "sv.nixfox.ca:51820";
|
||||
persistentKeepalive = 25;
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
|
@ -1,12 +1,44 @@
|
|||
{ lib, ... }:
|
||||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
./client
|
||||
./server
|
||||
];
|
||||
options.services.wg.server.enable = lib.mkEnableOption "Enable Wireguard server";
|
||||
|
||||
options.services.wireguard = with lib; {
|
||||
client.enable = mkEnableOption "Enable Wireguard client";
|
||||
server.enable = mkEnableOption "Enable Wireguard server";
|
||||
config = lib.mkIf config.services.wg.server.enable {
|
||||
systemd.network = {
|
||||
netdevs = {
|
||||
"50-wg0" = {
|
||||
netdevConfig = {
|
||||
Kind = "wireguard";
|
||||
Name = "wg0";
|
||||
MTUBytes = "1300";
|
||||
};
|
||||
wireguardConfig = {
|
||||
PrivateKeyFile = pkgs.writeText "wgserversecret" config.secrets.wg.serverKey;
|
||||
ListenPort = 51820;
|
||||
RouteTable = "main";
|
||||
};
|
||||
wireguardPeers = [
|
||||
{ # NixOS Config Key
|
||||
PublicKey = "OKUH/h6YSURI4vgeTZKQD15QsqaygdbTn1mAWzQp9S0=";
|
||||
AllowedIPs = [ "11.0.0.0/8" ];
|
||||
}
|
||||
{ # Pixel 9
|
||||
PublicKey = "dPCtjm67adMZCnyL1O2L+uUOk0RbjA9T/tht1r+qcE4=";
|
||||
AllowedIPs = [ "11.1.0.1/32" ];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
networks."wg0" = {
|
||||
matchConfig.Name = "wg0";
|
||||
address = [ "11.0.0.1/8" ];
|
||||
networkConfig = {
|
||||
IPMasquerade = "both";
|
||||
IPv4Forwarding = true;
|
||||
IPv6Forwarding = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall.allowedUDPPorts = [ 51820 ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
config = lib.mkIf config.services.wireguard.server.enable {
|
||||
systemd.network = {
|
||||
netdevs = {
|
||||
"50-wg0" = {
|
||||
netdevConfig = {
|
||||
Kind = "wireguard";
|
||||
Name = "wg0";
|
||||
MTUBytes = "1300";
|
||||
};
|
||||
wireguardConfig = {
|
||||
PrivateKeyFile = pkgs.writeText "wgserversecret" config.secrets.wg.serverKey;
|
||||
ListenPort = 51820;
|
||||
RouteTable = "main";
|
||||
};
|
||||
wireguardPeers = [
|
||||
{ # NixOS Config Key
|
||||
PublicKey = "OKUH/h6YSURI4vgeTZKQD15QsqaygdbTn1mAWzQp9S0=";
|
||||
AllowedIPs = [ "11.0.0.0/8" ];
|
||||
}
|
||||
{ # Pixel 9
|
||||
PublicKey = "dPCtjm67adMZCnyL1O2L+uUOk0RbjA9T/tht1r+qcE4=";
|
||||
AllowedIPs = [ "11.1.0.1/32" ];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
networks.wg0 = {
|
||||
matchConfig.Name = "wg0";
|
||||
address = [ "11.0.0.1/8" ];
|
||||
networkConfig = {
|
||||
IPMasquerade = "both";
|
||||
IPv4Forwarding = true;
|
||||
IPv6Forwarding = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall.allowedUDPPorts = [ 51820 ];
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue