One of the first things that irked me after my Precise installation was how DNS suddenly seemed slow. I normally use dnscache for local DNS caching and while setting it up this time, I noticed that oddly,
127.0.0.1 was already setup as my name server. Netstat told me that this was handled by DNSMasq for some reason. No worries, I thought, and I setup dnscache on
127.0.0.2 instead. I added the IP to the
prepend nameserver option in
/etc/dhcp/dhclient.conf and clicked on the NetworkManager applet to reconnect to my wireless (to trigger DHCP again).
/etc/resolv.conf continued to have the mysterious
127.0.0.1 as usual. Something had changed and I started looking for answers on the web. I found a very detailed explanation for the DNS resolving changes in Precise 12.04 in this blog post by Stéphane Graber. Apparently,
/etc/resolv.conf is not just completely “taken over” by resolvconf, but NetworkManager as well. There are some good reasons for this, but for my personal requirements, I can ignore those reasons right now. I like to have a say in the DNS server configuration on my system, and there doesn’t seem to be a good way to preferentially use my DNS servers. On top of this, the default DNS configuration on Precise is a non-caching one (for otherwise valid security reasons). Uh huh. NO. dnscache rules. It’s simple and to the point.
An additional look at this post by Mikhail Esteves with some trial and error, got me an easy solution.
It turns out that NetworkManager (NM) doesn’t care about any DNS based configuration in
/etc/dhcp/dhclient.conf as long as
/etc/NetworkManager/NetworkManager.conf has a line saying
To fix all this, do the following steps and the system behaviour changes to as it was previously before Precise. To summarize:
Comment the line
restart NetworkManager (
sudo restart network-manager)
127.0.0.1is now free to be used by dnscache. Configure dnscache to use this if you had modified the listening IP earlier
Put your preferential DNS servers in
/etc/dhcp/dhclient.confusing the line
prepend domain-name-servers 127.0.0.1;, and they will be added at the top of the name servers in
Reconnect to your network link to trigger DHCP and you are ready to go!
Ok, I must confess, all this didn’t really make DNS resolution on my system much faster :) - turns out my stupid ISP Airtel was responsible for most of it ( I am currently FUP-ed right now, and network is really weird in this state).comments powered by Disqus