大网数据广告活动
服务器运维问答

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

· 52CE 我爱测

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. I…

问题原文

原帖链接 · Boda Cydo · CC BY-SA 3.0

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?

已采纳解答

原帖链接 · Kzerza · CC BY-SA 3.0

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?

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-11-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。