How to Flush DNS Cache of Linux and Windows Client

We may need to flush DNS cache of our client when the site’s DNS has been changed.

Flush DNS cache of Linux with NetworkManager/dnsmasq

You may simply restart NetworkManager by

sudo systemctl restart NetworkManager

Flush DNS Cache on (Old) Linux with nscd

1) Use su – to get root privilege or sudo with the following command:

 # /etc/rc.d/init.d/nscd restart

or

# service nscd restart

Flush DNS Cache on Windows:

1) Log in as a Administrator on Windows XP and previous version.
2) “Start->run” then run “cmd.exe”.
3) At the command prompt run

ipconfig /flushdns

For Windows Vista, Windows 7 and later version:
1) “Start->All Programs->Accessories”
2) Right click on the command prompt and choose run as administrator.
3) At the command prompt run

ipconfig /flushdns

Flush DNS cache of Chrome

Open the URI:

chrome://net-internals/#dns

in Chrome’s address bar.

Then click the “Clear host cache” button in the configuration page.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

3 comments:

  1. The DNS may be probably also cached by your DNS provider. You can use the dig command to query the DNS info from your DNS server:

    dig @dns_server_address domain_name

    For example:

    [zma@localhost ~]$ dig @ns1.dreamhost.com fclose.com

    ; <> DiG 9.9.4-P2-RedHat-9.9.4-12.P2.fc20 <> @ns1.dreamhost.com fclose.com
    ; (1 server found)
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52886
    ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
    ;; WARNING: recursion requested but not available

    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 2800
    ;; QUESTION SECTION:
    ;fclose.com. IN A

    ;; ANSWER SECTION:
    fclose.com. 14400 IN A 64.90.49.224

    ;; Query time: 921 msec
    ;; SERVER: 66.33.206.206#53(66.33.206.206)
    ;; WHEN: Mon Apr 21 14:01:50 HKT 2014
    ;; MSG SIZE rcvd: 55

    [zma@localhost ~]$ dig @8.8.8.8 fclose.com

    ; <> DiG 9.9.4-P2-RedHat-9.9.4-12.P2.fc20 <> @8.8.8.8 fclose.com
    ; (1 server found)
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15587
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 512
    ;; QUESTION SECTION:
    ;fclose.com. IN A

    ;; ANSWER SECTION:
    fclose.com. 14399 IN A 64.90.49.224

    ;; Query time: 1865 msec
    ;; SERVER: 8.8.8.8#53(8.8.8.8)
    ;; WHEN: Mon Apr 21 14:01:59 HKT 2014
    ;; MSG SIZE rcvd: 55

  2. You may also need to flush certain programs’ own DNS cache.

    For example, for Chrome, “browse” chrome://net-internals/#dns

    And click on the “Clear host cache” can clear Chrome’s DNS cache.

Leave a Reply

Your email address will not be published. Required fields are marked *