Unable To Edit Resolv.conf

Home » CentOS » Unable To Edit Resolv.conf
CentOS 14 Comments

Hello,

I changed ISPs and need to update name servers in resolv.conf.

I have tried nano, gedit, Webmin, system-config-network and it won’t allow me to make the changes.

I have Network Manager turned off and when I enable it , eth0 and eth1 have no entries.

I enabled it, added the connections, but still no changes.

I’m stuck

TIA

14 thoughts on - Unable To Edit Resolv.conf

  • I know that in Fedora, resolv.conf is now some symlink to a NetworkManager file (I forget where).

    Try doing ls -l /etc/resolv.conf, and see if that’s the case in CentOS-7 as well. (I don’t use NM, so I’m not sure what the case is with it, as the machine I’m using had that change made, if it was needed, long ago. :) )

    If it does turn out to be a symlink, copy its information, if you need it, then delete the file, then recreate it.

    Hope this helps, but I’m not sure. It is a working solution in Fedora.

  • You haven’t done what I’ve done intentionally, flag /etc/resolv.conf immutable with “chattr +i /etc/resolv.conf” have you?

    I do this to keep Network Manager and other busybodies from making unwanted
    / unneeded changes.

    Al

  • I’ve tried to figure out how to get Network Manager to leave various configuration files alone and just gave up – resorting to cron job running as root every minute fixing them if they have been modified.

    I wish there was better documentation on how Network Manager is configured because I can’t figure out how to get it to behave.

    My home router – the caching nameserver it uses doesn’t enforce DNSSEC
    and crashes about once a week, requiring a restart. So I just don’t use it except for my phone and tablet, and just run unbound on my local machines, but Network Manager keeps trying to use the nameserver assigned by the router DHCP (which is the router) and other than a once a minute cron job, can’t figure out how to tell Network Manager to ignore the nameserver setting.

  • Have you tried adding PEERDNS=no to your ifcfg-device file? If that doesn’t work, you might be able to use NM_CONTROLLED=no as well.

    Barry

  • Hi,

    TD> I have tried nano, gedit, Webmin, system-config-network and it won’t allow TD> me to make the changes.

    Selinux enforcing mode activated?

    best regards

  • Have you tried setting PEERDNS=no in the
    /etc/sysconfig/network-scripts/ifcfg- script(s)?

    I have an ancient note here from 5.x days with the above fix.

    Al

  • That might work on my desktop but I don’t think it would work on my laptop where it seems to create new network scripts for every wifi network it connects to.

  • If you want to use NetworkManager, edit
    /etc/NetworkManager/NetworkManager.conf and add “dns=none” in the main section:

    [main]
    plugins=ifcfg-rh dns=none

    If you don’t want to use NetworkManager, then set PEERDNS=no and remove any DNS1, DNS2, etc settings in /etc/sysconfig/network-scripts/ifcfg-*

  • You can determine whether you’ve set the file’s immutable attribute using “lsattr”. You can remove it using “chattr -i”

LEAVE A COMMENT