idk
This commit is contained in:
parent
f904bbb423
commit
5f64523982
8 changed files with 506 additions and 477 deletions
54
mainWireguard.nix
Normal file
54
mainWireguard.nix
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
{config, lib, pkgs, ...}:
|
||||
let
|
||||
cfg = config.cos.mainWireguard;
|
||||
in
|
||||
{
|
||||
options.cos.mainWireguard = {
|
||||
enable = lib.mkEnableOption "enable";
|
||||
interface = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "wg0";
|
||||
};
|
||||
ip = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
port = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 51820;
|
||||
};
|
||||
privateKeyFile = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
networking.firewall.interfaces.${cfg.interface}.allowedUDPPorts = [
|
||||
cfg.port
|
||||
];
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
wireguard-tools
|
||||
];
|
||||
|
||||
networking.wireguard = {
|
||||
enable = true;
|
||||
interfaces = {
|
||||
${cfg.interface} = {
|
||||
ips = [ "${cfg.ip}/24" ];
|
||||
listenPort = 51820;
|
||||
|
||||
privateKeyFile = cfg.privateKeyFile;
|
||||
|
||||
peers = [
|
||||
{
|
||||
publicKey = "raOzdkhoag+sN2/KXz18F9ncmeTWhdmPJxQJkqsJ7FI=";
|
||||
allowedIPs = [ "10.100.0.0/24" ];
|
||||
endpoint = "50.116.49.95:51820";
|
||||
persistentKeepalive = 25;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue