Bug 1566656 - NetworkManager is updating /etc/resolv.conf even if "dns=none" is specified
Summary: NetworkManager is updating /etc/resolv.conf even if "dns=none" is specified
Keywords:
Status: CLOSED DUPLICATE of bug 1541031
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: NetworkManager
Version: 7.5
Hardware: x86_64
OS: Linux
unspecified
urgent
Target Milestone: rc
: ---
Assignee: sushil kulkarni
QA Contact: Desktop QE
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-04-12 17:23 UTC by Venkatesh Kavtikwar
Modified: 2018-04-13 11:56 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-13 11:56:36 UTC
Target Upstream Version:


Attachments (Terms of Use)

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 ***


Note You need to log in before you can comment on or make changes to this bug.