linux中的DNS缓存 [英] DNS caching in linux

查看:110
本文介绍了linux中的DNS缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对DNS缓存感到困惑。我正在编写一个小的转发代理服务器,并希望在Linux系统上使用操作系统DNS缓存。



如果我理解正确,那么浏览器级别有DNS缓存。然后在操作系统级别上有DNS缓存(Windows有它),我不知道Linux发行版是否默认是这样的)。



那么浏览器/ proxy_server如何使用操作系统DNS缓存?我试图找到我是否可以依靠Linux进行DNS缓存,而不是在我自己的代理服务器上进行。



谢谢

解决方案

在Linux上(可能大多数是Unix),没有操作系统级DNS缓存,除非 nscd 已安装并运行。即使这样,默认情况下,nscd的DNS缓存功能至少在Debian中被禁用,因为它被打破了。实际的结果是,您的Linux系统非常可能不会执行任何操作系统级DNS缓存。



您可以在应用程序中实现自己的缓存(就像他们鱿鱼,根据 diegows 的评论),但我建议反对它。这是很多工作,很容易弄错(nscd错了!!!),它可能不像一个专用的DNS缓存一样容易调整,并且它复制了您应用程序之外已经存在的功能。 p>

如果使用您的软件的最终用户需要进行DNS缓存,因为DNS查询负载足够大可能是一个问题,或者外部DNS服务器的RTT足够长一个问题,他们可以在与应用程序相同的计算机上安装缓存DNS服务器,例如 Unbound ,配置为缓存响应并将错误转发到常规DNS解析器。


I am confused about DNS caching. I am writing a small forward proxy server and want to use OS DNS cache on a Linux system.

If I understand correctly, then there is DNS caching at the browser level. Then there is DNS caching at OS level (Windows has it. I am not sure if Linux distros have it by default).

So, how does a browser/proxy_server use OS DNS caching? I am trying to find if I can rely on Linux for DNS caching instead of doing it on my own inside my proxy.

Thanks

解决方案

On Linux (and probably most Unix), there is no OS-level DNS caching unless nscd is installed and running. Even then, the DNS caching feature of nscd is disabled by default at least in Debian because it's broken. The practical upshot is that your linux system very very probably does not do any OS-level DNS caching.

You could implement your own cache in your application (like they did for Squid, according to diegows's comment), but I would recommend against it. It's a lot of work, it's easy to get it wrong (nscd got it wrong!!!), it likely won't be as easily tunable as a dedicated DNS cache, and it duplicates functionality that already exists outside your application.

If an end user using your software needs to have DNS caching because the DNS query load is large enough to be a problem or the RTT to the external DNS server is long enough to be a problem, they can install a caching DNS server such as Unbound on the same machine as your application, configured to cache responses and forward misses to the regular DNS resolvers.

这篇关于linux中的DNS缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆