Bug 1364895 - Updating /etc/resolv.conf failed sometimes
Summary: Updating /etc/resolv.conf failed sometimes
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: initscripts
Version: 7.1
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: David Kaspar [Dee'Kej]
QA Contact: Daniel Rusek
Filip Hanzelka
URL:
Whiteboard:
Depends On:
Blocks: 1203710 1298243 1380361 1393867 1420851 1465901 1466365 1357658 1400961
TreeView+ depends on / blocked
 
Reported: 2016-08-08 06:50 UTC by Akhil John
Modified: 2019-03-15 14:15 UTC (History)
6 users (show)

Fixed In Version: initscripts-9.49.40-2.el7
Doc Type: Release Note
Doc Text:
Network scripts now correctly update `/etc/resolv.conf` Network scripts have been enhanced to update the `/etc/resolv.conf` file correctly. Notably: * The scripts now update the `nameserver` and `search` entries in the `/etc/resolv.conf` file after the "DNS*" and "DOMAIN" options, respectively, have been updated in the `ifcfg-*` files in the `/etc/sysconfig/network-scripts/` directory * The scripts now also update the order of `nameserver` entries after it has been updated in the `ifcfg-*` files in `/etc/sysconfig/network-scripts/` * Support for the "DNS3" option has been added * The scripts now correctly process duplicate and randomly omitted "DNS*" options
Clone Of:
Environment:
Last Closed: 2018-04-10 18:24:45 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 22459 Configure None Why do manual changes made to '/etc/resolv.conf' files get overwritten on Red Hat Enterprise Linux ? 2019-03-15 14:15:36 UTC
Red Hat Product Errata RHBA-2018:0983 None None None 2018-04-10 18:26:24 UTC

Description Akhil John 2016-08-08 06:50:43 UTC
Description of problem:
Updating the DNS configuration in /etc/sysconfig/network-scripts/ifcfg-eth0 does not always trigger an update of /etc/resolv.conf if the system has booted.



Version-Release number of selected component (if applicable):
RHEL7 server without the NetworkManager packages
# uname -a
Linux f1moon1 3.10.0-229.4.2.el7.x86_64 #1 SMP Fri Apr 24 15:26:38 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux

# rpm -qa | egrep -i 'initscr|network'
dracut-network-033-241.el7_1.1.x86_64
initscripts-9.49.24-1.el7.x86_64



Steps to Reproduce:
1) Setup a RHEL7 server without the NetworkManager packages
-----------------------------------------------------------
# uname -a
Linux f1moon1 3.10.0-229.4.2.el7.x86_64 #1 SMP Fri Apr 24 15:26:38 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux

# rpm -qa | egrep -i 'initscr|network'
dracut-network-033-241.el7_1.1.x86_64
initscripts-9.49.24-1.el7.x86_64

# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.3.6
nameserver 192.168.13.6
search example.com

# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Generated by dracut initrd
NAME="eth0"
HWADDR="00:50:56:a2:5e:31"
ONBOOT=yes
NETBOOT=yes
UUID="7d677073-5b05-44ea-b09d-8ec823f42cdf"
BOOTPROTO=none
IPADDR="192.168.1.29"
NETMASK="255.255.255.0"
GATEWAY="192.168.1.254"
TYPE=Ethernet
DNS1="192.168.3.6"
DNS2="192.168.13.6"
DOMAIN=example.com

2) Remove /etc/resolv.conf.save
-------------------------------
# ll /etc/resolv.c*
-rw-r--r-- 1 root root 97 Aug  5 09:43 /etc/resolv.conf

3) Update the DNS2 in ifcfg-eth0
--------------------------------
# grep DNS /etc/sysconfig/network-scripts/ifcfg-eth0
DNS1="192.168.3.6"
DNS2="192.168.13.6"

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

# grep DNS /etc/sysconfig/network-scripts/ifcfg-eth0
DNS1="192.168.3.6"
DNS2="192.168.16.6"

# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.3.6
nameserver 192.168.13.6
search example.com

4) Reboot 
---------
# uptime
 09:49:39 up 1 min,  1 user,  load average: 0.31, 0.11, 0.04

5) Compare DNS entries in ifcfg-eth0 and resolv.conf
----------------------------------------------------
# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.3.6
nameserver 192.168.13.6
search example.com

# grep DNS /etc/sysconfig/network-scripts/ifcfg-eth0
DNS1="192.168.3.6"
DNS2="192.168.16.6"




Actual results:
The second DNS entry is still the old entry "192.168.13.6".

Expected results:
The second DNS entry has been updated to the new entry "192.168.16.6".

Additional info:
Swaping the entries DNS1 and DNS2 in ifcfg-eth0 also does not trigger an update of /etc/resolv.conf. 
Just after DNS1 has changed to a new ip address that does not match DNS2, the file resolv.conf will updated in a predictive way.

Comment 2 Akhil John 2016-08-08 09:58:13 UTC
Can we make this bug public ? customer is requesting for public access .

Comment 3 Lukáš Nykrýn 2016-08-08 10:52:48 UTC
(In reply to Akhil John from comment #2)
> Can we make this bug public ? customer is requesting for public access .
I am fine with that.

Comment 4 Lukáš Nykrýn 2016-08-08 11:04:03 UTC
> RHEL7 server without the NetworkManager packages

> # cat /etc/resolv.conf
> # Generated by NetworkManager

Are you really sure that NetworkManager is not installed on that system?

Anyway in your reproducer could you before the reboot add "set -x" to the end of /etc/init.d/functions so it looks like this:
----------------------------------------
[0 root@qeos-52 test]# tail /etc/init.d/functions 
                "x$1" = xtry-restart -o \
                "x$1" = xforce-reload -o \
                "x$1" = xcondrestart ] ; then

		systemctl_redirect $0 $1
		exit $?
	fi
fi

set -x
----------------------------------------
And then reboot the machine and attach the output of "journalctl -b" and "journalctl -b -u network.service"

Comment 5 Lukáš Nykrýn 2016-08-08 14:54:49 UTC
Looks like I have already fixed that: https://bugzilla.redhat.com/show_bug.cgi?id=1316019

Should be in 7.3.

Comment 6 Lukáš Nykrýn 2016-08-08 14:56:27 UTC

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

Comment 7 Lukáš Nykrýn 2016-08-08 15:04:07 UTC
Just for reference patch for rhel7 branch of initscripts:
https://git.fedorahosted.org/cgit/initscripts.git/commit/?h=rhel7-branch&id=21ee08c718692c6a4ff32204767638f0c3aafa65

Comment 8 Carsten Grohmann 2016-08-09 06:32:20 UTC
I wouldn't agree with closing this bug, because swapping the entries DNS1 and DNS2 in ifcfg-eth0 also does not trigger an update of /etc/resolv.conf.

Comment 9 Lukáš Nykrýn 2016-08-09 06:56:58 UTC
(In reply to Carsten Grohmann from comment #8)
> I wouldn't agree with closing this bug, because swapping the entries DNS1
> and DNS2 in ifcfg-eth0 also does not trigger an update of /etc/resolv.conf.

Ok, I will look into that part. Unfortunately it is quite late in 7.3 development and this is not a critical issue, so I don't think it will make it there.

Comment 10 Lukáš Nykrýn 2016-08-09 07:02:16 UTC
Also I must admit I was wrong in the case of DNS3. I have read the specification for resolving in glib and for rhel7 we have MAXNS set to 3. So that should be also supported in initscripts. I will look into that as well.

Comment 17 David Kaspar [Dee'Kej] 2017-10-09 10:23:11 UTC
Pull-request submitted into upstream:
https://github.com/fedora-sysv/initscripts/pull/131

Comment 29 Andrew Taylor 2018-02-26 00:53:06 UTC
*** Bug 1548871 has been marked as a duplicate of this bug. ***

Comment 35 errata-xmlrpc 2018-04-10 18:24:45 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:0983


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