Bug 1566656

Summary: NetworkManager is updating /etc/resolv.conf even if "dns=none" is specified
Product: Red Hat Enterprise Linux 7 Reporter: Venkatesh Kavtikwar <vkavtikw>
Component: NetworkManagerAssignee: sushil kulkarni <sukulkar>
Status: CLOSED DUPLICATE QA Contact: Desktop QE <desktop-qa-list>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 7.5CC: atragler, bgalvani, fgiudici, lrintel, ptalbert, rkhan, sababu, sukulkar, thaller
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-13 11:56:36 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Venkatesh Kavtikwar 2018-04-12 17:23:37 UTC
Description of problem:

NetworkManager is updating /etc/resolv.conf even if "dns=none" is specified.

When NetworkManager restarts for the first time after marking this change, it does update /etc/resolv.conf but from the second NetworkManager restart it does not. 


Version-Release number of selected component (if applicable):

NetworkManager-1.10.2-13.el7.x86_64
kernel-3.10.0-862.el7.x86_64


How reproducible:

1. Mark "dns=none" to /etc/NetworkManager/NetworkManager.conf 
2. Restart NetworkManager [1]
3. NetworkManager will overwrite content of /etc/resolv.conf
4. Restart NetworkManager again[2]
5. Now this will not change the content of /etc/resolv.conf


Steps to Reproduce:
1. "/etc/resolv.conf" before marking "dns=none" to /etc/NetworkManager/NetworkManager.conf 
======================

# cat /etc/resolv.conf
nameserver 10.0.0.1

2. Marking "dns=none" to /etc/NetworkManager/NetworkManager.conf 
======================

# cat /etc/NetworkManager/NetworkManager.conf  <<---- setting dns=none

[main]
plugins=ifcfg-rh
dns=none

3. # ls -l /run/NetworkManager/resolv.conf
-rw-r--r-- 1 root root 55 Apr 11 22:37 /run/NetworkManager/resolv.conf

[root@localhost ~]# ls -l /etc/resolv.conf
-rw-r--r-- 1 root root 21 Apr 11 22:39 /etc/resolv.conf


# cat /run/NetworkManager/resolv.conf <<---- before restarting NM
# Generated by NetworkManager
nameserver 192.168.122.1

4. Restart NetworkManager (first time)
======================

# systemctl restart NetworkManager


5. NetworkManager overwrites, content of /etc/resolv.conf 
======================

# cat /etc/resolv.conf   <<<--- old content 
# Generated by NetworkManager
nameserver 192.168.122.1
# cat /run/NetworkManager/resolv.conf    <<<--- old content
# Generated by NetworkManager
nameserver 192.168.122.1

# ls -l /etc/resolv.conf
-rw-r--r-- 1 root root 55 Apr 11 22:45 /etc/resolv.conf

# ls -l /run/NetworkManager/resolv.conf
-rw-r--r-- 1 root root 55 Apr 11 22:45 /run/NetworkManager/resolv.conf


6. Changing the content of "/etc/resolv.conf" 
======================

# cat /etc/resolv.conf
nameserver 10.0.0.1

7. Restart NetworkManager (second time)
======================

# cat /etc/resolv.conf
nameserver 10.0.0.1


Expected results:

NetworkManager should not overwrite content of "/etc/resolv.conf" when "dns=none" is marked.


Additional Info:

From the NetworkManager debug log, we see that NetworkManager updates "/etc/resolv.conf" while stopping it.

Apr 11 22:45:05 localhost.localdomain systemd[1]: Stopping Network Manager...

Apr 11 22:45:05 localhost.localdomain NetworkManager[720]: <debug> [1523466905.0376] dns-mgr: update-dns: updating resolv.conf <<---- at stop time NM is updating resolv.conf

Apr 11 22:45:05 localhost.localdomain systemd[1]: Starting Network Manager...

Apr 11 22:45:05 localhost.localdomain NetworkManager[2679]: <debug> [1523466905.1001] CONFIG:   dns=none
Apr 11 22:45:05 localhost.localdomain NetworkManager[2679]: <debug> [1523466905.1122] session-monitor: using systemd-logind session tracking
Apr 11 22:45:05 localhost.localdomain NetworkManager[2679]: <info>  [1523466905.1128] dns-mgr[0x7fa6ca819140]: init: dns=none, rc-manager=unmanaged
Apr 11 22:45:05 localhost.localdomain systemd[1]: Started Network Manager.
Apr 11 22:45:05 localhost.localdomain NetworkManager[2679]: <debug> [1523466905.3008] dns-mgr: update-dns: not updating resolv.conf

Comment 2 Sangam 2018-04-13 09:21:43 UTC
Hello Team,

Customer for the case 02066088, wants to track the progress of this bugzilla. So can we make this BZ public or can we add customer in CC for the latest updates?

Comment 3 Beniamino Galvani 2018-04-13 09:34:55 UTC
This is probably a duplicate of bug 1541031.

Comment 4 Thomas Haller 2018-04-13 09:51:08 UTC
In comment 0

> How reproducible:
>
> 1. Mark "dns=none" to /etc/NetworkManager/NetworkManager.conf 
> 2. Restart NetworkManager [1]
> 3. NetworkManager will overwrite content of /etc/resolv.conf

Restart means Stop+Start. I would suspect, that NetworkManager writes to resolve.conf during "Stop", and not afterwards.

Until "Stop" complets, NetworkManager was not told to reload the configuration from disk (e.g. via kill -HUP, systemctl reload), so, at that point NetworkManager is still in full control of resolv.conf until the process ends, and it's not immediately clear that NetworkManager updated resolv.conf wrongly.

At least, the bug talks not about NetworkManager writing something wrong to resolv.conf, instead it expects that editing the configuration file on disk alone, will immediately instruct NetworkManager to stop touching resolv.conf. That's not how it works. You need to either reload the configuration, or expect that the new configuration is honored on the next start (and not earlier). 

(In reply to Beniamino Galvani from comment #3)
> This is probably a duplicate of bug 1541031.

I think this is NOTABUG.

Comment 5 Venkatesh Kavtikwar 2018-04-13 11:07:53 UTC
Hello Thomas,

Thanks for your reply.

I agree with the above statement that NetworkManager will not read the configuration changes at the time of stopping but at the same time it should not update "/etc/resolv.conf" while going done.

It doesn't make any sense of updating "/etc/resolv.conf" while bringing the NetworkManager service down.

Comment 6 Thomas Haller 2018-04-13 11:56:36 UTC
(In reply to Venkatesh Kavtikwar from comment #5)
> Hello Thomas,
> 
> Thanks for your reply.
> 
> I agree with the above statement that NetworkManager will not read the
> configuration changes at the time of stopping but at the same time it should
> not update "/etc/resolv.conf" while going done.
> 
> It doesn't make any sense of updating "/etc/resolv.conf" while bringing the
> NetworkManager service down.

I think the subject of the bug is not correct and NOTABUG. Not correct, because if NM is really configured with dns=none, it shouldn't touch resolv.conf (and I don't think that is happening).

Note that you could at any time receive a DHCP lease that involves changes which cause to rewrite resolv.conf. That means, 

  - check content of /etc/resolv.conf
  - systemctl stop NetworkManager
  - check content of /etc/resolv.conf

always has a race, that before NetworkManager stops, something relevant happens that causes NetworkManager to rewrite resolv.conf, and that'd be correct behavior. 


bug 1541031 is about NetworkManager rewriting resolv.conf with undesired content during shut-down. I think as such, this bug is a duplicate (I agree with Beniamino).


Closing. Please comment/reopen, if you disagree. Thank you.

*** This bug has been marked as a duplicate of bug 1541031 ***