How To Flush Linux - UNIX DNS Cache
How To Flush Linux - UNIX DNS Cache
1 of 13
http://www.cyberciti.biz/faq/rhel-debian-ubuntu-flush-clear-dns-cache/
Tutorials
BASH Shell
Troubleshooting
Nginx
Networking
MySQL
Google Cloud Platform
Amazon Cloud Computing
Rackspace Cloud Computing
Linux
CentOS
Debian / Ubuntu
Ubuntu Linux
Suse
RedHat and Friends
Slackware Linux
UNIX
AIX
Mac OS X
FreeBSD
FreeBSD Jails (VPS)
Openbsd
Solaris
See all tutorial topics
Blog
About
Contact us
Forum
Linux Scripting Guide
RSS/FEED
Linux FAQ / Howtos
2 of 13
http://www.cyberciti.biz/faq/rhel-debian-ubuntu-flush-clear-dns-cache/
Nscd caches libc-issued requests to the Name Service. If retrieving NSS data is fairly expensive, nscd is
able to speed up consecutive access to the same data dramatically and increase overall system
performance. Just restart nscd:
$ sudo /etc/init.d/nscd restart
OR
# service nscd restart
OR
# service nscd reload
This daemon provides a cache for the most common name service requests. The default configuration file,
/etc/nscd.conf, determines the behavior of the cache daemon.
OR
# service dnsmasq restart
You can also use rndc command as follows flush out all cache:
# rndc restart
OR
# rndc exec
BIND v9.3.0 and above will support flushing all of the records attached to a particular domain name with
rndc flushname command. In this example flush all records releated to cyberciti.biz domain:
# rndc flushname cyberciti.biz
It is also possible to flush out BIND views. For example, lan and wan views can be flushed using the
following command:
# rndc flush lan
# rndc flush wan
OR
$ sudo dscacheutil -flushcache
5/22/2014 11:15 AM
3 of 13
http://www.cyberciti.biz/faq/rhel-debian-ubuntu-flush-clear-dns-cache/
/etc/hosts act as the static table lookup for hostnames. You need to remove and/or update records as per
your requirements under Unix like operating systems:
# vi /etc/hosts
Sample outputs:
127.0.0.1
localhost
127.0.1.1
wks01.WAG160N
wks01
# The following lines are desirable for IPv6 capable hosts
::1
ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
10.37.34.2
build
192.168.1.10
nas01
192.168.1.11
nas02
192.168.1.12
nas03
#192.168.2.50
nfs2.nixcraft.net.in nfs2
#192.168.2.51
nfs1.nixcraft.net.in nfs1
172.168.232.50 nfs1.nixcraft.net.in nfs1
172.168.232.51 nfs2.nixcraft.net.in nfs2
192.168.1.101
vm01
See also:
Related: Windows Vista / XP Flush DNS Cache with ipconfig Command
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!
Featured Articles:
30 Cool Open Source Software I Discovered in 2013
30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
Top 30 Nmap Command Examples For Sys/Network Admins
25 PHP Security Best Practices For Sys Admins
20 Linux System Monitoring Tools Every SysAdmin Should Know
20 Linux Server Hardening Security Tips
Linux: 20 Iptables Examples For New SysAdmins
Top 20 OpenSSH Server Best Security Practices
Top 20 Nginx WebServer Best Security Practices
20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
15 Greatest Open Source Terminal Applications Of 2012
My 10 UNIX Command Line Mistakes
Top 10 Open Source Web-Based Project Management Software
Top 5 Email Client For Linux, Mac OS X, and Windows Users
The Novice Guide To Buying A Linux Laptop
{ 29 comments read them below or add one }
1 NoPremium.org April 18, 2008 at 8:32 am
it dont work for me i have ubunu 7.10
Reply
2 kazoolist July 10, 2008 at 10:54 pm
5/22/2014 11:15 AM
4 of 13
http://www.cyberciti.biz/faq/rhel-debian-ubuntu-flush-clear-dns-cache/
I my experience service nscd restart does not clear NSCDs cache. service nscd reload
does, however.
Reply
3 Subhash July 27, 2010 at 5:26 pm
That is correct!
Reply
4 James Mills September 19, 2008 at 8:32 am
Actually, in Bind, you can flush the daemons cache by doing
rndc flush
Reply
5 Lost Eagle January 31, 2011 at 4:01 pm
Thank U
This rndc flush help lot restart doesnt flush
Have a nice day
Reply
6 RudyD February 4, 2009 at 12:35 pm
Whoops!
It seems that not the perfect view for precise approach. It seems that if I use bind and there is a
resolv.conf too not always the bind is in use. (Ubuntu) Other important machine (with debian),
there is just resolv.conf. Anyhow I have tried to restart (hope works) the /etc/init.d/dns-clean and it
seems it worked. But there were reports that this did not do the job. Anyhow, I want to make sure
that especially my debian system without restarting, even the networking, how can I just restart
the name resolution to the newly set values and how to get sure that it is done well?
Thanks!
Reply
7 Tricky April 26, 2009 at 11:50 pm
If nscd is in use, try nscd -i hosts as root.
As per James Mills, rndc flush if using bind.
If none of these work you might not have a DNS cache to flush anyway and the problem DNS entry
may be stored elsewhere, such as your firefox DNS cache, your routers cache, or another upstream
DNS caching server.
Reply
5/22/2014 11:15 AM
5 of 13
http://www.cyberciti.biz/faq/rhel-debian-ubuntu-flush-clear-dns-cache/
5/22/2014 11:15 AM
6 of 13
http://www.cyberciti.biz/faq/rhel-debian-ubuntu-flush-clear-dns-cache/
7 of 13
http://www.cyberciti.biz/faq/rhel-debian-ubuntu-flush-clear-dns-cache/
DNS entry could be cached elsewhere, for example on your router or your ISPs DNS server.
Reply
19 andre July 22, 2011 at 7:18 am
on Debian Squeeze/wheezy:
Usage: /etc/init.d/nscd {start|stop|force-reload|restart|status}
Reply
20 m4h September 15, 2011 at 8:10 am
Manish ->
Change from:
192.168.1.1 admin.domain.com admin
TO:
192.168.1.1 admin admin.domain.com admin
Reply
21 david.chen February 3, 2012 at 2:45 am
why not just use
nscd -i hosts
nscd -i passwd .
to flush the cache
Reply
22 Tim March 21, 2012 at 1:23 pm
The articles recomendations are distribution specific and depend on how the init scripts are set up
and what they do. The proper way to flush the cache on nscd is nscd -i hosts and for named,
rndc flush
Anything else, like /etc/init.d/nscd reload depends on how your distro wrote the init script. Just
because that works for you on Fedora does not mean Debian or someone else set it up that way as
well.
Reply
23 Som June 13, 2012 at 8:44 pm
If a user wants to flush DNS cache and if the user uses Internet via LAN connection ,the best way
to do so is changing the DNS address manually . He just needs to alter the DNS entry .Setting
alternative DNS address as primary address will solve the issue instantly. This trick worked for me .
I faced the same problem . I am aLinux user .so , I installed NSCD client and tried to flush the
cache . But , it could not solve my issue .i solved it myself just changing the DNS entry . It worked
for me instantly .I kept the new entry for two days without any problem and later reinstated the
older entry
Reply
5/22/2014 11:15 AM
8 of 13
http://www.cyberciti.biz/faq/rhel-debian-ubuntu-flush-clear-dns-cache/
5/22/2014 11:15 AM
9 of 13
http://www.cyberciti.biz/faq/rhel-debian-ubuntu-flush-clear-dns-cache/
Tagged as: /etc/init.d/dnsmasq, /etc/init.d/named, /etc/init.d/nscd, clear dns cache in linux, clear dns cache
on linux, clearn dns cache, dns queries, dnsmasq, flush dns cache in linux, flush dns cache on linux, flush
5/22/2014 11:15 AM
10 of 13
http://www.cyberciti.biz/faq/rhel-debian-ubuntu-flush-clear-dns-cache/
linux dns cache, how to clear cache, linux clear dns cache, linux flush dns cache, named, nscd, redhat
flush dns cache
Previous Faq: Fingerprint / Identify Remote Web Server
Next Faq: Debian / Ubuntu Linux WARNING: The following packages cannot be authenticated! Error
and Solution
Related Faqs
5/22/2014 11:15 AM
11 of 13
http://www.cyberciti.biz/faq/rhel-debian-ubuntu-flush-clear-dns-cache/
Monit: Monitor BIND 9 (named) Name Server and Auto Restart SSH
If It Does Not Respond
Find Out If My DNS Server Free From DNS Cache Poisoning Bug Or
Not
5/22/2014 11:15 AM
12 of 13
http://www.cyberciti.biz/faq/rhel-debian-ubuntu-flush-clear-dns-cache/
5/22/2014 11:15 AM
13 of 13
http://www.cyberciti.biz/faq/rhel-debian-ubuntu-flush-clear-dns-cache/
Follow
Tweets
nixCraft Linux Blog
21 May
@nixcraft
Interview with Linus Torvalds the legendary
inventor of #Linux and founder of the Open Source
crusade huffingtonpost.com/billrobinson/t
Show Summary
nixCraft Linux Blog
21 May
@nixcraft
Been there, done that. #life #humour
#LifeIsLikeThat #sysadmin
pic.twitter.com/Gr82hdHIIy
Tweet to @nixcraft
Subscribe to nixCraft
Learn something new about Linux/Unix by email
Enter your email address:
2000-2014 nixCraft. All rights reserved. Privacy Policy - Terms of Service - Questions or Comments We are proudly powered by Linux + Nginx + WordPress.
The content is copyrighted to nixCraft and may not be reproduced on other websites.
5/22/2014 11:15 AM