9 cfg = config.services.technitium-dns-server;
10 stateDir = "/var/lib/technitium-dns-server";
20 options.services.technitium-dns-server = {
21 enable = mkEnableOption "Technitium DNS Server";
23 package = mkPackageOption pkgs "technitium-dns-server" { };
25 openFirewall = mkOption {
29 Whether to open ports in the firewall.
30 Standard ports are 53 (UDP and TCP, for DNS), 5380 and 53443 (TCP, HTTP and HTTPS for web interface).
31 Specify different or additional ports in options firewallUDPPorts and firewallTCPPorts if necessary.
35 firewallUDPPorts = mkOption {
36 type = with types; listOf int;
39 List of UDP ports to open in firewall.
43 firewallTCPPorts = mkOption {
44 type = with types; listOf int;
47 5380 # web interface HTTP
48 53443 # web interface HTTPS
51 List of TCP ports to open in firewall.
52 You might want to open ports 443 and 853 if you intend to use DNS over HTTPS or DNS over TLS.
57 config = mkIf cfg.enable {
58 systemd.services.technitium-dns-server = {
59 description = "Technitium DNS Server";
60 wantedBy = [ "multi-user.target" ];
61 after = [ "network.target" ];
64 ExecStart = "${cfg.package}/bin/technitium-dns-server ${stateDir}";
68 StateDirectory = "technitium-dns-server";
69 WorkingDirectory = stateDir;
75 KillSignal = "SIGINT";
78 LockPersonality = true;
79 NoNewPrivileges = true;
80 PrivateDevices = true;
84 ProtectControlGroups = true;
86 ProtectHostname = true;
87 ProtectKernelLogs = true;
88 ProtectKernelModules = true;
89 ProtectKernelTunables = true;
90 ProtectSystem = "strict";
92 RestrictAddressFamilies = "AF_INET AF_INET6 AF_UNIX AF_NETLINK";
93 RestrictNamespaces = true;
94 RestrictRealtime = true;
95 RestrictSUIDSGID = true;
97 AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
98 CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];
102 networking.firewall = mkIf cfg.openFirewall {
103 allowedUDPPorts = cfg.firewallUDPPorts;
104 allowedTCPPorts = cfg.firewallTCPPorts;
108 meta.maintainers = with lib.maintainers; [ fabianrig ];