nameserver in /etc/resolv.conf vs /etc/sysconfig/ifcfg-eth0 on Centos 6 / RHEL 6 server

0

If nameservers are configured with both nameserver entries in /etc/resolv.conf and DNS1/DNS2 entries in /etc/sysconfig/network-scripts/ifcfg-eth0 on a Centos 6 / RHEL 6 server, which one will take precedence? Please help! Thanks in advance!!

Karunkar Borah

Posted 2019-01-06T13:42:16.307

Reputation: 1

Answers

0

The system uses the info in the /etc/resolv.conf file. However, that file is created from the entry in the sysconfig folder (e.g., at reboot).

joat

Posted 2019-01-06T13:42:16.307

Reputation: 466

Thanks but if I set PEERDNS=no in /etc/sysconfig/ifcfg-eth0 it should not update /etc/resolv.conf. Which DNS server will ultimately be used by the system?? – Karunkar Borah – 2019-01-06T14:39:46.227

0

Well i tried it out and found out that /etc/resolv.conf takes presedence over /etc/sysconfig/network-scripts/ifcfg-eth file. You can go through my configuration and a dig output below. I rebooted the system after initially saving this configuration.

[root@KKcentOSVM karunakar]# cat /etc/resolv.conf
; custom entries
search localdomain
nameserver 8.8.8.8
nameserver 4.2.2.2
[root@KKcentOSVM karunakar]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
HWADDR=00:0C:29:E7:72:60
TYPE=Ethernet
BOOTPROTO=none
IPADDR=192.168.186.131
NETMASK=255.255.255.0
GATEWAY=192.168.186.2
NAME=eth1
NM_CONTROLLED=no
ONBOOT=yes
DNS1=8.8.4.4
DNS2=4.2.2.2
PEERDNS=no
[root@KKcentOSVM karunakar]# dig www.google.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.68.rc1.el6_10.1 <<>> www.google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 38527
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.google.com.            IN  A

;; ANSWER SECTION:
www.google.com.     69  IN  A   216.58.200.132

;; Query time: 196 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Mon Jan  7 20:50:00 2019
;; MSG SIZE  rcvd: 48

You can verify from the third last line from the output of

dig www.google.com

which is

;; SERVER: 8.8.8.8#53(8.8.8.8)

that the url was resolved by the nameserver 8.8.8.8 set in /etc/resolv.conf rather than 8.8.4.4 set in /etc/sysconfig/network-scripts/ifcfg-eth1

Karunkar Borah

Posted 2019-01-06T13:42:16.307

Reputation: 1