Today, a quick how-to on how to:
- Override nameservers provided by your DHCP server by the ones from https://www.opennicproject.org, 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 18.104.22.168, 22.214.171.124;
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 nameserver 126.96.36.199 nameserver 188.8.131.52
You can find the closest name servers to your location here: http://wiki.opennicproject.org/ClosestT2Servers
Use dnsmasq as local DNS cache
Easy, install dnsmasq package, then put this in /etc/dnsmasq.d/custom:
# disable dnsmasq DNS server port=0 # Activate dnsmasq local cache listen-address=127.0.0.1
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:
[main] #(some other conf can be present before this line) dns=dnsmasq
You can now check than /etc/resolv.conf contain this:
# Generated by NetworkManager nameserver 127.0.0.1