I'm having problems related to DNS solving in my Ubuntu 9.10.
Prior complaining to my ISP I would like to refresh my local DNS cache, like in Windows we do ipconfig /flushdns
.
How can I do that in Ubuntu?
Øhh, ubuntu doesn't cache DNS per default. So there is nothing to flush! (but maybe your SOHO router does). Installing nscd will make ubuntu cache DNS, afterwhich you can clear your cache - but this is besides the point, when you don't have it installed yet!
nslookup
tells me that the response comes from server 127.0.0.1
. But - to my knowledge - I have no DNS caching installed (neither nscd
nor dnsmasq
). I'm on Kubuntu... could this be a KDE Network Manager thing?
Ubuntu 12.04 onwards uses dnsmasq for a local cache. Sending it a SIGHUP (sudo killall -HUP dnsmasq) will re-read the cache.
NOTES
When it receives a SIGHUP, dnsmasq clears its cache and then re-loads /etc/hosts and /etc/ethers and any file given by --dhcp-hostsfile, --dhcp-optsfile or --addn-hosts. The dhcp lease change script is called for all existing DHCP leases. If --no-poll is set SIGHUP also re-reads /etc/resolv.conf. SIGHUP does NOT re-read the configuration file.
dig
for testing whether the cache really has been cleared. I wanted to clear the cache on one of my OpenWrt routers for which I tried dig @192.168.0.3 nixos.org
several times (any existent domain will do). While cached, it would usually have a query time of 1ms, but after each time I issued killall -HUP dnsmasq
(as root) on the router I got about 27ms after each time I cleared it.
Commented
Apr 20, 2014 at 23:50
Try the following:
sudo /etc/init.d/dns-clean start
It works for me.
I just had this problem with a site for which I changed the DNS, and googling for a solution I found this page.
In my experience Firefox sometimes keeps its own DNS cache and doesn't clear it in time. So if you're viewing a site in Firefox, and keep seeing the old site, trying Chrome might solve the problem. If that works, you can clear the cache in Firefox. This happened in Ubuntu, I don't know if this happens on Windows or OSX as well.
I don't have nscd installed. I noticed however that in the terminal the new DNS is found several minutes later, so the problem solved itself.
Depending on the context of your question you might need to clear the cache of your web browser too.
In Firefox this is done by: preferences -> privacy -> clear your recent history [just tick the "cache" checkbox there]
In Chrome: Navigate to chrome://net-internals/#dns and press the "Clear host cache" button. (see another answer)