2

I have an Oracle Linux 7.5 VM on VirtualBox setup with a static IP address. My DNS servers have changed since I first setup the VM. I modified the file /etc/sysconfig/network-scripts/ifcfg-enp0s3 to have the IP address for the new DNS server but, when I reboot, /etc/resolv.conf keeps getting recreated with the old DNS server ip addresses.

[root@oel72 ~]# cd /etc/sysconfig/network-scripts
[root@oel72 network-scripts]# cat ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=58524328-dc73-4b1f-9a56-e3a5d5a4edd5
DEVICE=enp0s3
ONBOOT=yes
IPV6_ADDR_GEN_MODE=stable-privacy
DNS1=IPADDRESSOFNEWDNSSERVER
DOMAIN="my domains edited for post"
IPADDR=10.0.2.6
PREFIX=24
GATEWAY=10.0.2.2
IPV6_PRIVACY=no
PROXY_METHOD=none
BROWSER_ONLY=no
[root@oel72 ~]# cat /etc/resolv.conf
# Generated by NetworkManager

search my domains edited for post
nameserver IPADDRESSOFOLDDNS1
nameserver IPADDRESSOFOLDDNS2
nameserver IPADDRESSOFOLDDNS3

I edited out the actual IP addresses and actual domain names. Hopefully that will not obscure the issue. I'm guessing that there is some command to make the system pull in /etc/sysconfig/network-scripts/ifcfg-enp0s3 again and that it will store the IP address for the new DNS but I cannot find instructions for doing so. Does anyone know how to update these?

  • 1
    Is any DNS configured in /etc/sysconfig/network? – Thomas May 23 at 18:12
  • No, that file is empty. [root@oel72 sysconfig]# cat /etc/sysconfig/network # Created by anaconda – Bobby Durrett May 23 at 18:57
  • A couple of sites recommended that I run chattr +i /etc/resolv.conf. This seems to work but seems like a kludge or hack. – Bobby Durrett May 23 at 19:48
  • 1
    You may try using NetworkManager to set your DNS URLs/addresses. I'm not sure you'll find it on Oracle Linux, but nmtui is an easy way to do it from the command line. NetworkManager uses plugins to read/write network configuration files, but it doesn't monitor them. – fra-san May 30 at 10:47
  • 1
    Random suggestions (being short of good ones): 1) check if NetworkManager settings in /etc/NetworkManager/NetworkManager.conf differ from the default: the documentation (man 5 NetworkManager.conf) lists several and possibly convoluted ways to manage resolv.conf. 2) Use auditd to check which program is editing your resolv.conf. 3) If applicable, prevent NetworkManager from modifying resolv.conf (again, refer to man Networkmanager.conf, especially the dns and rc-manager keys). – fra-san May 31 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.