Static Configuration: Prevent /etc/resolv.conf From Being Overwritten On First Reboot

Home » CentOS » Static Configuration: Prevent /etc/resolv.conf From Being Overwritten On First Reboot
CentOS 2 Comments

Hi,

Here’s something that’s puzzling me.

Starting from a minimal installation of CentOS 7, network configuration is DHCP.

I’m launching nmtui to define a static configuration.

I’m providing the IP address as well as the gateway, but no DNS server.

I’m quitting nmtui and I’m editing /etc/resolv.conf to provide my DNS server:

# /etc/resolv.conf nameserver 192.168.0.254

I reboot my server, and I don’t know why, but my /etc/resolv.conf has been overwritten:

# Generated by NetworkManager

So I edit this file again:

# /etc/resolv.conf nameserver 192.168.0.254

And starting from here, it works, meaning /etc/resolv.conf is not overwritten on subsequent reboots.

Q: how can I prevent /etc/resolv.conf from being overwritten on the initial reboot? I vaguely remember having to kill some process before editing it, but unfortunately I don’t remember which one.

Cheers,

Niki

Microlinux – Solutions informatiques durables
7, place de l’église – 30730 Montpezat Site : https://www.microlinux.fr Blog : https://blog.microlinux.fr Mail : info@microlinux.fr Tél. : 04 66 63 10 32
Mob. : 06 51 80 12 12

2 thoughts on - Static Configuration: Prevent /etc/resolv.conf From Being Overwritten On First Reboot

  • Nicolas Kovacs wrote:

    One way to do this is to create the file /etc/dhcp/dhclient-enter-hooks that contains:

    make_resolv_conf(){
    :
    }

    Or, add the line ‘PEERDNS=no’ to the matching /etc/sysconfig/network-scripts/ifcfg-XXXX file

    James Pearson