How do I flush the DNS cache on Win, Mac, Linux computers?
Solution 1:
Windows
ipconfig /flushdns
Mac (OS X 10.5)
dscacheutil -flushcache
Linux
If you are using nscd:
nscd -i hosts
In Windows you can turn off client-side DNS caching using this command:
net stop dnscache
It stops the DNS Caching service. It will restart with the next rebooting.
Solution 2:
This is what Google replied:
To flush DNS cache in Microsoft Windows (Win XP, Win ME, Win 2000):-
- Start -> Run -> type cmd
- in command prompt, type ipconfig /flushdns
- Done! You Window DNS cache has just been flush.
To flush the DNS cache in Linux, restart the nscd daemon:-
- To restart the nscd daemon, type /etc/rc.d/init.d/nscd restart in your terminal
- Once you run the command your linux DNS cache will flush.
To flush the DNS cache in Mac OS X Leopard:-
- type lookupd -flushcache in your terminal to flush the DNS resolver cache.
ex: bash-2.05a$ lookupd -flushcache
- Once you run the command your DNS cache (in Mac OS X) will flush.
To flush the DNS cache in Mac OS X:-
- type dscacheutil -flushcache in your terminal to flush the DNS resolver cache.
ex: bash-2.05a$ dscacheutil -flushcache
- Once you run the command your DNS cache (in Mac OS X Leopard) will flush.
Solution 3:
Ubuntu does not install a caching DNS server by default. Given the likelihood of your router or ISP is using a caching DNS server instead, it seems a bit silly to bother.
If you are having problems and aren't running nscd, check try resetting the next step in the DNS recusive lookup chain.
Solution 4:
A small warning, If you need to flush a DNS cache, flushing it on your end machine may not work as expected. Generally the DNS cache on your end machine is fetched from the closest possible DNS server, which is generally on your primary router/dhcp server.
This will not be obvious to most, but it might explain why when you try to execute the aforementioned linux DNS cache flushes you find nscd
wasn't running to start with. ( I haven't seen a setup that runs this by default for quite a while ).
You need to check your networks dns-server/router/firewall/modem manual / user interface for how this works. Generally rebooting them does the trick, but be warned, I have seen boxes that memorize DNS caches over reboot.
And even then, when you've done all of the above right, you could go straight ahead and pollute your DNS cache with a false entry the first time you look outside your network to the nearest hop, usually your ISP, who are prone to having a stale DNS cache.