I am admin for several Linux and FreeBSD servers and here is a problem I have:

The servers run a tool that does a lot of DNS queries every minute for the entire network. When it does a query, the result gets cached system-wide. If a DNS entry changes, the change gets picked up much later.

What would be the way to flush DNS cache? My boss almost pushes me to move software to Windows that has ipconfig /flushdns call. I told my boss I will resolve this issue during weekend and on Monday all Linux and FreeBSD will flush cache. If I don't do that he will force me to make Windows servers and run software on them.

How to flush DNS cache on Linux and FreeBSD?

  • what linux brand do you use? Versions of those linux/freebsd systems? Are you running nscd on them? Are they running a dns caching server or do they forward their queries to another dns server? Nov 1, 2014 at 8:18
  • I use Debian, and FreeBSD 10. I don't run nscd. They just use resolving C library calls as far as I remember to do resolving. No caching.
    – Boda Cydo
    Nov 1, 2014 at 11:41
  • I am not sure how debian or freebsd behave, but on my fedora laptop I see no client dns caching whatsoever. Every time I fire a dns query I see it in a wireshark trace. Maybe the caching is not in the OS but in the application layer you use? PS: just tested in a debian 6 host (old stable) we have still around and I cannot reproduce the behaviour you mention. Every time I change a dummy record in a test zone in our dns server, it gets properly resolved in the debian host, no caching at all. Nov 1, 2014 at 15:25
  • FreeBSD does not have a DNS Resolver Cache by default. You would have to install/configure a full DNS server (unbound is installed with base, but not configured by default), or a caching client such as nscd (installed with base, but not configured by default)
    – Chris S
    Nov 1, 2014 at 18:32
  • @BodaCydo Can you clarify whether it actually is the client which is caching or whether it is the configured resolver server (from resolv.conf) that is doing this caching you speak of. Nov 1, 2014 at 18:43

4 Answers 4


I don't get your question because you say some nonsense.

If you are on a Linux/Unix system that does not run a DNS server 'named/bind/other' the system does not cache any DNS query. Applications (DNS clients) just query the DNS server every time without caching, they query the DNS server every time. If you use a DNS server 'named/bind' and want to clear the cache just restart this service (Freebsd: /etc/rc.d/named restart) but there is no point for this.

If a DNS entry changes, the change gets picked up much later.

How this can be? Do you run a DNS server or not? If you run a secondary DNS server you just get a copy of the zone from primary server and there is no point to flush cache. You can push the server update zone from the primary server by deleting the zone file and restarting your DNS service. If you run primary DNS and want to update zone information, change the serial in zone and restart service:

# /etc/rc.d/named restart (for named)
# rndc (for bind9)

To update zone information. To check if you get right dns answer use:

# dig @dns_server example.com

pushes me to move software to Windows that has ipconfig /flushdns

For what?


Presuming you are running the Name Service Caching Daemon, you run "nscd -i hosts" as root

  • What operating system is this? It it installed and used by default on Linux and FreeBSD?
    – Boda Cydo
    Nov 1, 2014 at 5:14
  • Installed by default on *BSD. Feb 14, 2017 at 12:53
  • no such thing in base openbsd
    – ffuentes
    Apr 14 at 13:09

What you might want to do is a combination of the following.

If you know that various entries change in your DNS zone change quickly, then set the TTL down to a smaller value for the zone.

Generally, there is a NameServerCacheDaemon (nscd) process that runs in standard release Linux (not sure about FreeBSD). A quick way to clear the cache is to restart this daemon.

Finally, if you are running a caching DNS server on your hosts, you can easily restart the dns service and that will clear the cache. I think that there might even be a cache clear if you use the dns control command.

  • What do you think if I suggested my boss to simply query name servers of the domains directly? Rather than caching anything at all locally or on local network.
    – Boda Cydo
    Nov 1, 2014 at 11:46

For FreeBSD you can delete the arp by the following command

arp -da

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.