2021-05-11 14:32:58 +07:00
|
|
|
{ config, pkgs, ... }: {
|
2023-09-04 12:28:19 +07:00
|
|
|
networking.firewall =
|
|
|
|
|
let
|
|
|
|
|
iptables = "${pkgs.iptables}/bin/iptables";
|
|
|
|
|
genCmds = type: ''
|
|
|
|
|
${iptables} -${type} nixos-fw -p tcp --source 192.168.0.0/16 -j nixos-fw-accept ${if type == "D" then " || true" else ""}
|
|
|
|
|
${iptables} -${type} nixos-fw -p udp --source 192.168.0.0/16 -j nixos-fw-accept ${if type == "D" then " || true" else ""}
|
|
|
|
|
'';
|
|
|
|
|
in {
|
2021-09-20 13:42:43 +00:00
|
|
|
enable = true;
|
2022-01-11 11:39:56 +07:00
|
|
|
allowedUDPPortRanges = [ { from = 20000; to = 20100; } ];
|
|
|
|
|
allowedTCPPortRanges = [ { from = 20000; to = 20100; } ];
|
2021-09-20 13:42:43 +00:00
|
|
|
trustedInterfaces = [ "wg0" ];
|
2024-07-02 12:31:41 +10:00
|
|
|
logRefusedConnections = false;
|
2023-09-04 12:28:19 +07:00
|
|
|
|
|
|
|
|
extraCommands = genCmds "I";
|
|
|
|
|
extraStopCommands = genCmds "D";
|
2021-09-20 13:42:43 +00:00
|
|
|
};
|
2021-07-15 08:39:09 +07:00
|
|
|
|
|
|
|
|
services.openssh = {
|
|
|
|
|
enable = true;
|
2023-06-18 21:31:27 +07:00
|
|
|
settings = {
|
|
|
|
|
PermitRootLogin = "no";
|
|
|
|
|
PasswordAuthentication = false;
|
|
|
|
|
X11Forwarding = true;
|
|
|
|
|
};
|
2021-09-20 18:40:15 +07:00
|
|
|
|
|
|
|
|
hostKeys = [
|
|
|
|
|
{
|
|
|
|
|
bits = 4096;
|
2022-08-09 15:17:30 +07:00
|
|
|
path = "/persist/ssh_host_rsa_key";
|
2021-09-20 18:40:15 +07:00
|
|
|
rounds = 100;
|
|
|
|
|
type = "rsa";
|
|
|
|
|
}
|
|
|
|
|
{
|
2022-08-09 15:17:30 +07:00
|
|
|
path = "/persist/ssh_host_ed25519_key";
|
2021-09-20 18:40:15 +07:00
|
|
|
rounds = 100;
|
|
|
|
|
type = "ed25519";
|
|
|
|
|
}
|
|
|
|
|
];
|
2021-07-15 08:39:09 +07:00
|
|
|
};
|
2021-05-11 14:32:58 +07:00
|
|
|
|
|
|
|
|
security = {
|
|
|
|
|
polkit.enable = true;
|
|
|
|
|
sudo.enable = false;
|
|
|
|
|
doas = {
|
|
|
|
|
enable = true;
|
|
|
|
|
extraRules = [
|
|
|
|
|
{
|
2021-07-15 19:57:49 +07:00
|
|
|
groups = [ "wheel" ];
|
2021-05-11 14:32:58 +07:00
|
|
|
keepEnv = true;
|
|
|
|
|
persist = true;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|