Linux – How to flush DNS resolver cache on Linux (and FreeBSD)

cachedomain-name-systemfreebsdlinux

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?

Best Answer

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?