`resolve.conf` not using the values defined in `networking.nameservers`

I have the following config:

   networking = {
    dhcpcd.extraConfig = "nohook resolv.conf";
    networkmanager = {
      enable = true;
      dns = "none";
    };
    nameservers = [
      "127.0.0.1"
      "::1"
      "2a06:98c1:54::3cfe"
    ];
};
  services.resolved.enable = false;
  networking.resolvconf.enable = false;

But when I check resolve.conf I see these values

# Generated by resolvconf
nameserver 1.1.1.1
nameserver 8.8.8.8

What I am doing wrong? I want to see the same entries as defined in nameservers

You could try checking of cloud-init is overriding these?

Alternatively, dhcpd also overrides this stuff sometimes.

(From 25.05 we found that the nix ‘source of truth’ isn’t quite as truthy as it used to be for networking related stuff due to these other two sources of truth.)

I had the same problem and in the end manually created resolve.conf so I would be interested in a solution as well. This is especially annoying as tailscale mDNS doesn’t really work then.

yeah I currently manually create it

  environment.etc."resolv.conf".text = ''
    # Generated by environment.etc (NixOS static DNS fix)
    nameserver 127.0.0.1
    nameserver ::1
    # Trust the AD (authentic data) flag and use EDNS(0)
    options trust-ad edns0
  '';
1 Like

I’m not sure how you came up with that given that it’s not a valid resolv.conf file, a better way to declare the nameservers might be

environment.etc."resolv.conf".text = ''
  # Use the local DNS resolver
  nameserver 127.0.0.1
  nameserver ::1

  # Trust the AD (authentic data) flag and use EDNS(0)
  options trust-ad edns0
'';
1 Like

thanks, corrected my config

1 Like

If you disable resolvconf even the static entries from networking.nameservers will not be installed, so this is not the right solution.

# Generated by resolvconf

This is strange, because with resolvconf.enable = false if some program invokes resolvconf to update /etc/resolv.conf it should fail with this message:

resolvconf is disabled on this system but was used anyway

I would say that either you didn’t really disable it, or are looking at an old file. Please, check what’s inside /etc/resolvconf.conf.

Anyway, with NetworkManager you can use services.networkmanager.insertNameservers to provide some servers with higher priority than those from DHCP.