10 cfg = config.services.routedns;
11 settingsFormat = pkgs.formats.toml { };
14 options.services.routedns = {
15 enable = mkEnableOption (lib.mdDoc "RouteDNS - DNS stub resolver, proxy and router");
18 type = settingsFormat.type;
19 example = literalExpression ''
21 resolvers.cloudflare-dot = {
22 address = "1.1.1.1:853";
25 groups.cloudflare-cached = {
27 resolvers = ["cloudflare-dot"];
29 listeners.local-udp = {
30 address = "127.0.0.1:53";
32 resolver = "cloudflare-cached";
34 listeners.local-tcp = {
35 address = "127.0.0.1:53";
37 resolver = "cloudflare-cached";
41 description = lib.mdDoc ''
42 Configuration for RouteDNS, see <https://github.com/folbricht/routedns/blob/master/doc/configuration.md>
47 configFile = mkOption {
48 default = settingsFormat.generate "routedns.toml" cfg.settings;
49 defaultText = "A RouteDNS configuration file automatically generated by values from services.routedns.*";
51 example = literalExpression ''"''${pkgs.routedns}/cmd/routedns/example-config/use-case-1.toml"'';
52 description = lib.mdDoc "Path to RouteDNS TOML configuration file.";
56 default = pkgs.routedns;
57 defaultText = literalExpression "pkgs.routedns";
59 description = lib.mdDoc "RouteDNS package to use.";
63 config = mkIf cfg.enable {
64 systemd.services.routedns = {
65 description = "RouteDNS - DNS stub resolver, proxy and router";
66 after = [ "network.target" ]; # in case a bootstrap resolver is used, this might fail a few times until the respective server is actually reachable
67 wantedBy = [ "multi-user.target" ];
68 wants = [ "network.target" ];
69 startLimitIntervalSec = 30;
72 Restart = "on-failure";
75 LimitNOFILE = 1048576;
77 AmbientCapabilities = "CAP_NET_BIND_SERVICE";
78 NoNewPrivileges = true;
79 ExecStart = "${getBin cfg.package}/bin/routedns -l 4 ${cfg.configFile}";
83 meta.maintainers = with maintainers; [ jsimonetti ];