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!!
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).
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 18.104.22.168 nameserver 22.214.171.124 [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=126.96.36.199 DNS2=188.8.131.52 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 184.108.40.206 ;; Query time: 196 msec ;; SERVER: 220.127.116.11#53(18.104.22.168) ;; WHEN: Mon Jan 7 20:50:00 2019 ;; MSG SIZE rcvd: 48
You can verify from the third last line from the output of
;; SERVER: 22.214.171.124#53(126.96.36.199)
that the url was resolved by the nameserver 188.8.131.52 set in /etc/resolv.conf rather than 184.108.40.206 set in /etc/sysconfig/network-scripts/ifcfg-eth1