Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I just updated the DNS record (ns1, ns2, ns3.myhostingcompany.com) for a site I've got hosted, but I still get the domain registrar parking page. I'd like to see if the problem is Ubuntu's cached DNS records. Is there a way to clear Ubuntu's DNS cache? (if such a thing exists?)

share|improve this question

7 Answers

up vote 9 down vote accepted

For 11.10 and below

Ubuntu doesn't cache dns records by default so unless you've installed a dns cache there isn't anything to clear.

DNS records are likely cached by your provider's DNS servers so if you want to check if the DNS changes you made were successful you can interrogate a DNS server from your domain hosting service with dig:

dig -t a ns1.myhostingcompany.com @domain_registrar_dns_server

It you want Ubuntu to start caching dns I recommend installing pdnsd together with resolvconf. nscd is buggy and not advisable.

share|improve this answer
1  
Any references as to why nscd is buggy? Is it still buggy today (2012-10)? – jjmontes Sep 26 '12 at 12:13

12.04

Ubuntu 12.04 uses dnsmasq which is built into network-manager, but it doesn't cache dns so there is no need to flush it. Here is a sample line from my syslog to prove that point:

dnsmasq[2980]: started, version 2.59 cache disabled

There is also no need for any configuration of dnsmasq. If you are running with stock settings it won't be caching dns, as for it to do so you have to explicitly set it up as this Ubuntu article describes.

If you wanted to refresh your settings you could disable and then enable networking or run

sudo service network-manager restart

This restarts dnsmasq because it is built in to network-manager; check your syslog for the evidence for this.

If you are using a wired connection with dhcp network manager will be taking the settings direct from your router and your connection will be automatically established when you login to Ubuntu. You could check that the settings are correct in your router if you can access it via the web interface, and perhaps reboot it if necessary. If it is a general problem with dns, you could try using Google dns instead of your isp dns, and more information on that is detailed here.

share|improve this answer

For 12.04:

Ubuntu 12.04 does cache DNS using dnsmasq ( see man dnsmasq). Use the following to clear the cache:

sudo kill -HUP $(pgrep dnsmasq)
share|improve this answer
Thank you! You are the first I've seen mention anything about 12.04's default caching! – Slokun Sep 13 '12 at 21:22
1  
12.04 does not cache dns by default- check your syslog after restarting network-manager; it will have an entry that shows dnsmasq is starting with cache-disabled. – Mik Sep 14 '12 at 21:02

sudo /etc/init.d/nscd restart

http://www.ubuntugeek.com/howto-clearflush-dns-cache-in-ubuntu.html

Also as a note you can check and see if your DNS changes have propagated using dig and looking up against someone else other than your default DNS servers. In this case google DNS.

dig @8.8.8.8 example.com

share|improve this answer
3  
Worth noting that nscd isn't installed by default. – Scaine Jan 18 '11 at 20:05

Personally, I'd use OpenDNS and use their Cache Check function to force a refresh just to make sure the changes work but you can't guarantee they'll refresh for your users within 48 hours.

DNS is a slow beast. Patience will keep you sane.

share|improve this answer
+1 I use OpenDNS as well clear cache is very useful. – Mark Davidson Aug 13 '10 at 21:38
I'm suspicious of OpenDNS. I was happy with it at first, but then I started getting suspicious; though I guess if it's a choice between ISP and OpenDNS, I'm better off with OpenDNS, right? – Jono Aug 15 '10 at 20:23
I'd say OpenDNS is the lesser evil. They'd like to monetise your traffic but only on bad domain hits. – Oli Aug 15 '10 at 22:35

If you are using nscd:

sudo /etc/init.d/nscd restart

It's worth mentioning that it might not be the OS that is caching it. Everyone likes to cache DNS... Some tests:

Check to see if it's the new or old IP. Most browsers cache DNS as well, so if you haven't restarted Chromium or whatever you might not be seeing the latest.

ping yourdomain.com

Switch your local nameserver in the /etc/resolv.conf to another provider, google or level , examples:

nameserver 8.8.8.8
nameserver 4.2.2.2

And then ping again.

Check to make sure your router isn't caching DNS in any form. (Varies by router/firmware/etc)

Finally, patience. DNS can take a bit of time to propagate throughout the internet.

share|improve this answer
2  
If using NetworkManager and DHCP /etc/resolve.conf will get flushed when the DHCP lease expires, so you will have to set a static ip in NetworkManager to get this to work over longer time. – Source Lab Aug 13 '10 at 21:53

I used the following command to flush the dns cache on my 12.10 ubuntu box and it worked fantastic.

sudo kill -HUP $(pgrep dnsmasq)

Another helpful signal is the SIGUSR1 which dump a little statistic to syslog or as it is note from man dnsmasq:

In --no-daemon mode or when full logging is enabled (-q), a complete dump of the contents of the cache is made.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.