10 cfg = config.services.routedns;
11 settingsFormat = pkgs.formats.toml { };
14 options.services.routedns = {
15 enable = mkEnableOption "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";
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 = "Path to RouteDNS TOML configuration file.";
55 package = mkPackageOption pkgs "routedns" { };
58 config = mkIf cfg.enable {
59 systemd.services.routedns = {
60 description = "RouteDNS - DNS stub resolver, proxy and router";
61 after = [ "network.target" ]; # in case a bootstrap resolver is used, this might fail a few times until the respective server is actually reachable
62 wantedBy = [ "multi-user.target" ];
63 wants = [ "network.target" ];
64 startLimitIntervalSec = 30;
67 Restart = "on-failure";
70 LimitNOFILE = 1048576;
72 AmbientCapabilities = "CAP_NET_BIND_SERVICE";
73 NoNewPrivileges = true;
74 ExecStart = "${getBin cfg.package}/bin/routedns -l 4 ${cfg.configFile}";
78 meta.maintainers = with maintainers; [ jsimonetti ];