Centos – manually configure resolv.conf

centosdnsmasqnetworkingnetworkmanager

I am trying to setup dnsmasq on my machine, however I am having an issue with setting the order or nameservers correctly.

My interface is assigned DNS servers via NetworkManager and DHCP, and those will, seemingly, take priority no matter what I do; I need to completely ignore the nameserver I am sent via DHCP and use localhost only.

I have tried modifying /etc/sysconfig/network-scripts/ifcfg-*, adding DNS1=127.0.0.1, however I am then presented with the fowwloing warning message on restart of NetworkManager

dnsmasq[24391]: ignoring nameserver 127.0.0.1 - local interface

I have also tried different configurations with

/etc/NetworkManager/NetworkManager.conf
dns=dnsmasq # both on and off

All with no avail.

I am running CentOS7, and my question is this:

What do I need to configure to ensure that my system always uses 127.0.0.1 as the default, and only nameserver?

Best Answer

if your interface is configured using dhcp, then you should use the dhcp client settings. The setting you probably want to try is supersede domain-name-servers 127.0.0.1 as seen here: https://unix.stackexchange.com/questions/136117/ignore-dns-from-dhcp-server-in-ubuntu but I have never tried it in centos, so not really sure which file you need to edit