Today, a quick how-to on how to:

  • Override nameservers provided by your DHCP server by the ones from, when you are using network-manager
  • Use Network-Manager with dnsmasq to speed up DNS resolution

I assume you are using your Linux machine as a desktop, not a server, and with network-manager.

Always use OpenNIC name servers

In /etc/dhcp/dhclient.conf, add this line, this will override DNS provided by your DHCP server:

supersede domain-name-servers,;

You can put several servers separated per commas.

Restart network-manager, then you can check /etc/resolv.conf file has been written with the OpenNIC nameservers.

# Generated by NetworkManager

You can find the closest name servers to your location here:

Use dnsmasq as local DNS cache

Easy, install dnsmasq package, then put this in /etc/dnsmasq.d/custom:

# Activate dnsmasq local cache

To inform network-manager than you want to use dnsmasq as local DNS resolver, add this line in the [main] section of /etc/NetworkManager/NetworkManager.conf file:

#(some other conf can be present before this line)

You can now check than /etc/resolv.conf contain this:

# Generated by NetworkManager

Enjoy !

Useful links: