• How To Flush Linux / UNIX DNS Cache

Under MS-Windows you can use the ipconfig command to flush dns cache. However, Linux and UNIX provides various ways to flush cache. Linux can run nscd or BIND or dnsmasq as the name service caching daemon. Large and work-group servers may use BIND or dnsmasq as a dedicated caching server to speed up queries. [HTML_REMOVED]HowTo: Flush nscd dns cache[HTML_REMOVED] 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:[HTML_REMOVED]

$ sudo /etc/init.d/nscd restart

OR[HTML_REMOVED]

#     service nscd restart <br />

OR[HTML_REMOVED]

#     service nscd reload<br />

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. [HTML_REMOVED]Flush dnsmasq dns cache[HTML_REMOVED] dnsmasq is a lightweight DNS, TFTP and DHCP server. It is intended to provide coupled DNS and DHCP service to a LAN. Dnsmasq accepts DNS queries and either answers them from a small, local, cache or forwards them to a real, recursive, DNS server. This software is also installed many cheap routers to cache dns queries. Just restart the dnsmasq service to flush out dns cache:[HTML_REMOVED]

    $ sudo /etc/init.d/dnsmasq restart<br />

OR[HTML_REMOVED]

  # service dnsmasq restart

[HTML_REMOVED]

A caching BIND server obtains information from another server (a Zone Master) in response to a host query and then saves (caches) the data locally. All you have to do is restart bind to clear its cache:[HTML_REMOVED]

    # /etc/init.d/named restart<br />

You can also use rndc command as follows flush out all cache:<br />

    # rndc restart <br />

OR<br />

    # rndc exec<br />

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:[HTML_REMOVED]

    # rndc flushname cyberciti.biz<br />

It is also possible to flush out BIND views. For example, lan and wan views can be flushed using the following command:[HTML_REMOVED]

    # rndc flush lan<br />
    # rndc flush wan

[HTML_REMOVED]

Type the following command as root user:[HTML_REMOVED]

    # dscacheutil -flushcache<br />

OR[HTML_REMOVED]

    $ sudo dscacheutil -flushcache<br />

If you are using OS X 10.5 or earlier try the following command:[HTML_REMOVED]

    lookupd -flushcache

[HTML_REMOVED]

/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:[HTML_REMOVED]

    # vi /etc/hosts<br />

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     dev
192.168.1.10    server
192.168.1.11    nas02
192.168.1.12    nas03
192.168.1.101   vm01

That's it.


    This article was last modified: Feb. 19, 2016, 10:38 p.m.

    0 Comments

    Please log in to leave a comment.

    Add or change tags.

    A comma-separated list of tags.

    Share

    Hacker News

    Top