Help Center/ Huawei Cloud EulerOS/ FAQs/ What Do I Do If the resolv.conf File Is Modified by a Network Service Restart?
Updated on 2025-09-04 GMT+08:00

What Do I Do If the resolv.conf File Is Modified by a Network Service Restart?

Symptom

After the system or the network service is restarted, the value of nameserver (DNS server IP addresses) in /etc/resolv.conf is changed.

Possible Cause

This may be caused by the PEERDNS and RESOLV_MODS parameters in the network interface configuration file.

During the restart of the network service, the /etc/sysconfig/network-scripts/ifup-post and /etc/sysconfig/network-scripts/ifdown-post scripts check for RESOLV_MODS=no and PEERDNS=no in the network interface configuration file (for example, /etc/sysconfig/network-scripts/ifcfg-*). If the two parameters or either of them is not found, the scripts modify /etc/resolv.conf.

Parameter description:

  1. PEERDNS: whether DNS servers can be changed in /etc/resolv.conf. If DHCP is used, the default value is yes.
    • yes: If DNS configurations exist in /etc/resolv.conf, change DNS servers in the file.
    • no: DNS servers in /etc/resolv.conf cannot be changed.
  2. RESOLV_MODS: whether to write DNS servers into the configuration file.
    • yes: Write the values of MS_DNS1 and MS_DNS2 into /etc/resolv.conf.
    • no: DNS servers in /etc/resolv.conf cannot be changed.

Solution

Add the following content to the network interface configuration file /etc/sysconfig/network-scripts/ifcfg-* and restart the network service:

PEERDNS=no 
RESOLV_MODS=no