1 # Module for rdnssd, a daemon that configures DNS servers in
2 # /etc/resolv/conf from IPv6 RDNSS advertisements.
4 { config, lib, pkgs, ... }:
8 mergeHook = pkgs.writeScript "rdnssd-merge-hook" ''
9 #! ${pkgs.runtimeShell} -e
10 ${pkgs.openresolv}/bin/resolvconf -u
19 services.rdnssd.enable = mkOption {
22 #default = config.networking.enableIPv6;
24 Whether to enable the RDNSS daemon
25 ({command}`rdnssd`), which configures DNS servers in
26 {file}`/etc/resolv.conf` from RDNSS
27 advertisements sent by IPv6 routers.
36 config = mkIf config.services.rdnssd.enable {
39 assertion = config.networking.resolvconf.enable;
40 message = "rdnssd needs resolvconf to work (probably something sets up a static resolv.conf)";
43 systemd.services.rdnssd = {
44 description = "RDNSS daemon";
45 after = [ "network.target" ];
46 wantedBy = [ "multi-user.target" ];
49 # Create the proper run directory
51 touch /run/rdnssd/resolv.conf
52 chown -R rdnssd /run/rdnssd
54 # Link the resolvconf interfaces to rdnssd
55 rm -f /run/resolvconf/interfaces/rdnssd
56 ln -s /run/rdnssd/resolv.conf /run/resolvconf/interfaces/rdnssd
61 rm -f /run/resolvconf/interfaces/rdnssd
66 ExecStart = "@${pkgs.ndisc6}/bin/rdnssd rdnssd -p /run/rdnssd/rdnssd.pid -r /run/rdnssd/resolv.conf -u rdnssd -H ${mergeHook}";
68 PIDFile = "/run/rdnssd/rdnssd.pid";
72 users.users.rdnssd = {
73 description = "RDNSSD Daemon User";
77 users.groups.rdnssd = {};