LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-01-2015, 03:50 AM   #1
ulto
Member
 
Registered: Apr 2004
Posts: 52

Rep: Reputation: 1
/etc/resolv.conf vs DNS1="x.x.x.x" in Redhat


In simple terms what is the difference between the two and what takes precedence?
In my experience the /etc/resolve.conf file will win out but I have seen when we get network issues that the network interface will use its own configuration file.

Does the interface hold this information somewhere in its cache when it starts up?
 
Old 05-01-2015, 04:30 AM   #2
RMLinux
Member
 
Registered: Jul 2006
Posts: 260

Rep: Reputation: 37
that is the way you put your DNS SERVER on that file.

; generated by /sbin/dhclient-script
search localdomain
nameserver [DNS IP HERE]
nameserver [DNS IP HERE]

that is in my setup.
 
Old 05-01-2015, 09:39 AM   #3
mddnix
Member
 
Registered: Mar 2013
Location: Bengaluru, India
Distribution: Redhat, Arch, Ubuntu
Posts: 500

Rep: Reputation: 137Reputation: 137
Network in Redhat is either user specific or system-wide. When it is user specific, the settings are stored in GConf database and GNOME keyring, and are only available during login session for those users who created it. On the other hand, system-wide settings are stored under /etc/sysconfig/network-scripts/ directory in ifcfg- configuration files.

User specific setting can be made through nm-applet and uses NetworkManager service/unit. On the other hand, system-wide settings can be made through ifcfg-xxx file and uses network service/unit. You can also make user specific settings system-wide by checking 'Available to all users' in nm-applet.

You are not supposed to edit /etc/resolv.conf file. It is automatically filled by the setting you have set in /etc/sysconfig/network-script/ifcfg-xxxx file. Make sure PEERDNS is set to YES.

DOMAIN=domain.name
DNS1=8.8.8.8
DNS2=8.8.4.4
PEERDNS=yes
 
1 members found this post helpful.
Old 05-03-2015, 09:06 PM   #4
ulto
Member
 
Registered: Apr 2004
Posts: 52

Original Poster
Rep: Reputation: 1
Thanks for the reply. Where does it say from Redhat that you are not supposed to edit the /etc/resolve.conf file in favour of /etc/sysconfig/network-scripts/ifcfg-ethX files with a DNS=x.x.x.x field specified. If one has both filled out with different DNS servers, which one will get called first and why?
 
Old 05-03-2015, 10:41 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,602

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
It gets overwritten. The file itself should say "# Generated by NetworkManager" as the first line.

It is overwritten as the network devices are initialized.
 
Old 05-03-2015, 10:52 PM   #6
ulto
Member
 
Registered: Apr 2004
Posts: 52

Original Poster
Rep: Reputation: 1
I never stated that I have NetworkManager running. Our SOE builds for servers have NetworkManager disabled by default.

Further reading leads me to believe that resolv.conf is the only file that is being referenced for DNS lookups.
If you have DNS1 set in your interface config file then you have to also reference PEERDNS in how to hanndle it.

Having PEERDNS=NO to me is pointless, why have DNS set in the interface config file in this case?

If the PEERDNS is missing, by looking at the logic in /etc/sysconfig/network-scripts/ifup-post then these DNS servers set in the interface file WILL overwrite what is in /etc/resolv.conf.
So a missing PEERDNS is much like a PEERDNS='yes'. If I am right, be careful with this!

However, is there best practice here? People mention that you should not manually edit the resolv.conf file, but where are people getting this information from? Is there a whitepaper from Redhat that states this or are people assuming that everyone runs NetworkManager in their setup so by default think that only a 'process' should edit the /etc/resolv.conf file?
 
Old 05-04-2015, 06:57 AM   #7
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,602

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
/etc/resolv.conf gets overwritten by several things - the scripts /etc/sysconfig/network-scripts/ifcfg-xxx files, /etc/sysconfig/network (sometimes), DHCP client (depending on its configuration), and NetworkManager. (BTW, not sure how this fits in, but /usr/lib/systemd/systemd-resolved also has a hand in it. It seems (according to the manpage) to replace the /etc/resolv.conf with a symbolic link to a /run/systemd/resolve/resolv.conf)

At one time there was a "# do not edit this file" warning put in the file. Instead, it has a reference to what modified the file.

It has been getting harder to trace the changes ever since systemd has been added to the system since much of the startup is being hidden, but /etc/resolv.conf has (within the RH world at least) become almost untouchable.

Found out how systemd-resolved gets into it: It is a caching only name server that modified resolv.conf to include it in the search. (I missed a sentence "It also generates /run/systemd/resolve/resolv.conf for compatibility which may be symlinked from /etc/resolv.conf")

Last edited by jpollard; 05-04-2015 at 07:06 AM.
 
1 members found this post helpful.
Old 05-05-2015, 12:27 AM   #8
ulto
Member
 
Registered: Apr 2004
Posts: 52

Original Poster
Rep: Reputation: 1
OK, thanks for the heads up.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] "log_fqdn on" and "logformat" aren't included in the conf. file ?‏ ngiw2012 Linux - Software 3 06-05-2014 01:36 AM
understanding "domain" option in /etc/resolv.conf m4rtin Linux - Networking 6 09-25-2012 11:27 AM
"domain-name" and "host-name" options in dhcpd.conf m4rtin Linux - Server 3 09-20-2012 09:21 AM
xorg.conf : Explanation of "Viewport" and "Virtual" uncle-c Linux - Newbie 1 01-24-2011 12:04 PM
Problems configuring "xorg.conf" with "ATI FGLRX" BlueSpirit Slackware 3 09-16-2006 03:01 PM


All times are GMT -5. The time now is 02:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration