Nixpkgs: Empty networking.nameservers wipes /etc/resolv.conf after a rebuild

Created on 14 May 2019  路  6Comments  路  Source: NixOS/nixpkgs

Issue description

nixos-rebuild --switchwipes nameservers in /etc/resolv.conf when no networking.nameservers is set.

This began to happen a week or two ago, I think...

Someone else seems to be experiencing this: https://www.reddit.com/r/NixOS/comments/bohkz2/nixosrebuild_switch_causes_my_internet_to_die/

May be related to #61230.

Steps to reproduce

configuration.nix:

networking.networkmanager.enable = true;
# nothing about namesevers here.

After a fresh boot, the /etc/resov.conf is generated by NetworkManager (probably generated by resolvconf then overwritten by NetworkManager):

# Generated by NetworkManager
nameserver <whatever is pushed by my dhcp server>

After a nixos-rebuild --switch:

# Generated by resolvconf
options edns0

No resolvers available :disappointed:

Quick fix: disconnect/reconnect to the network or manually edit the file.

Why would resolvconf rewrite this is no nameservers are defined?

If I define some:

networking.nameservers = [ "1.0.0.1" "1.1.1.1" ];

At boot, my resolv.conf is still generated by NetworkManager. After a rebuild, it's overwritten by networking.nameservers:

# Generated by resolvconf
nameserver 1.0.0.1
nameserver 1.1.1.1
options edns0

With networking.networkmanager.dns = "none", we can tell NetworkManager to not update resolv.conf. Would it be possible to have an option for the other way around?

In the doc for networking.nameservers:

The list of nameservers. It can be left empty if it is auto-detected through DHCP.

If it's empty it's supposed to not update /etc/resolv.conf then, right?

I'm a bit confused, so please tell me if I missed something :slightly_smiling_face:

Technical details

  • system: "x86_64-linux"
  • host os: Linux 5.0.14, NixOS, 19.09pre179307.bc94dcf5002 (Loris)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.2.2
  • channels(root): "nixos-19.09pre179307.bc94dcf5002, home-manager, nixos-hardware"
  • channels(stanislas): ""
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

All 6 comments

I also have this problem. It seems to be because NetworkManager's default setting for rc-manager has changed from "resolvconf" to "symlink" - at least the behavior indicates this, even if the documentation states that "symlink" is and was the default setting.

I've fixed it in my config by setting
networking.networkmanager.extraConfig = '' [main] rc-manager=resolvconf '';

As mentioned here, it seems like #60904 might be related?
In particular:

# Default is symlink, we previously used resolvconf, dunno.
    "-Dconfig_dns_rc_manager_default=resolvconf"

Ah, interesting. That would probably solve this as well...

Ping.
Any progress on fixing this? / What would be the right approach to fix this in nixpkgs?

I believe this is fixed now by 80acb28. Can reopen if not.

I think I just had this re-occur, but I don't understand the technical details. Could someone confirm? I'm on 45179675a9a231d457cbac98db92c192794af1b1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grahamc picture grahamc  路  3Comments

chris-martin picture chris-martin  路  3Comments

domenkozar picture domenkozar  路  3Comments

vaibhavsagar picture vaibhavsagar  路  3Comments

tomberek picture tomberek  路  3Comments