Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty networking.nameservers wipes /etc/resolv.conf after a rebuild #61490

Closed
angristan opened this issue May 14, 2019 · 6 comments · Fixed by #62955
Closed

Empty networking.nameservers wipes /etc/resolv.conf after a rebuild #61490

angristan opened this issue May 14, 2019 · 6 comments · Fixed by #62955

Comments

@angristan
Copy link
Member

Issue description

nixos-rebuild --switch wipes 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 😞

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 🙂

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
@angristan angristan changed the title nixos-rebuild --switch wipes nameservers in /etc/resolv.conf Empty networking.nameservers wipes /etc/resolv.conf after a rebuild May 14, 2019
@talyz
Copy link
Contributor

talyz commented May 22, 2019

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
'';

@evanjs
Copy link
Member

evanjs commented May 22, 2019

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"

@talyz
Copy link
Contributor

talyz commented May 23, 2019

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

talyz added a commit to talyz/nixpkgs that referenced this issue May 24, 2019
Add an option to set the rc-manager parameter in NetworkManager.conf,
which controls how NetworkManager handles resolv.conf. This sets the
default rc-manager to "resolvconf", which solves NixOS#61490. It
additionally allows the user to change rc-manager without interference
from configuration activations.
sboehler pushed a commit to sboehler/nixos-config that referenced this issue May 30, 2019
evanjs added a commit to evanjs/nixos_cfg that referenced this issue May 30, 2019
@xaverdh
Copy link
Contributor

xaverdh commented Jun 6, 2019

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

evanjs added a commit to evanjs/nixos_cfg that referenced this issue Jun 10, 2019
@abbradar abbradar mentioned this issue Jun 10, 2019
10 tasks
alyssais pushed a commit that referenced this issue Jul 3, 2019
Add an option to set the rc-manager parameter in NetworkManager.conf,
which controls how NetworkManager handles resolv.conf. This sets the
default rc-manager to "resolvconf", which solves #61490. It
additionally allows the user to change rc-manager without interference
from configuration activations.
@alyssais
Copy link
Member

alyssais commented Jul 3, 2019

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

@alyssais alyssais closed this as completed Jul 3, 2019
angristan added a commit to angristan/nixos-config that referenced this issue Jul 12, 2019
@NorfairKing
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants