当前位置:首页 > 操作系统 > Linux

linux – 不使用nscd进行缓存的DNS查询

我正在尝试使用nscd(Nameservices Cache Daemon)在本地缓存DNS,因此我可以停止使用Bind来执行此操作.我已经开始了,ntpd似乎试图使用它.但主机的其他一切似乎都忽略了它.例如,如果我挖掘apache.org 3次,它们都不会达到缓存.我正在使用nscd -g查看缓存统计信息以确定它是否已被使用.我还调高了调试日志级别以查看是否可以看到它命中,查询甚至没有命中nscd.

的nsswitch.conf

# Begin /etc/nsswitch.conf
passwd: files
group: files
shadow: files

publickey: files

hosts: cache files dns
networks: files

protocols: files
services: files
ethers: files
rpc: files

netgroup: files
# End /etc/nsswitch.confenter code here

nscd.conf

#
# /etc/nscd.conf
#
# An example Name Service Cache config file.  This file is needed by nscd.
#
# Legal entries are:
#
#       logfile                 <file>
#       debug-level             <level>
#       threads                 <initial #threads to use>
#       max-threads             <maximum #threads to use>
#       server-user             <user to run server as instead of root>
#               server-user is ignored if nscd is started with -S parameters
#       stat-user               <user who is allowed to request statistics>
#       reload-count            unlimited|<number>
#       paranoia                <yes|no>
#       restart-interval        <time in seconds>
#
#       enable-cache            <service> <yes|no>
#       positive-time-to-live   <service> <time in seconds>
#       negative-time-to-live   <service> <time in seconds>
#       suggested-size          <service> <prime number>
#       check-files             <service> <yes|no>
#       persistent              <service> <yes|no>
#       shared                  <service> <yes|no>
#       max-db-size             <service> <number bytes>
#       auto-propagate          <service> <yes|no>
#
# Currently supported cache names (services): passwd, group, hosts, services
#

    logfile                 /var/log/nscd.log
    threads                 4
    max-threads             32
    server-user             nobody
#   stat-user               somebody
    debug-level             9
#   reload-count            5
    paranoia                no
#   restart-interval        3600

    enable-cache            passwd          yes
    positive-time-to-live   passwd          600
    negative-time-to-live   passwd          20
    suggested-size          passwd          211
    check-files             passwd          yes
    persistent              passwd          yes
    shared                  passwd          yes
    max-db-size             passwd          33554432
    auto-propagate          passwd          yes

    enable-cache            group           yes
    positive-time-to-live   group           3600
    negative-time-to-live   group           60
    suggested-size          group           211
    check-files             group           yes
    persistent              group           yes
    shared                  group           yes
    max-db-size             group           33554432
    auto-propagate          group           yes

    enable-cache            hosts           yes
    positive-time-to-live   hosts           3600
    negative-time-to-live   hosts           20
    suggested-size          hosts           211
    check-files             hosts           yes
    persistent              hosts           yes
    shared                  hosts           yes
    max-db-size             hosts           33554432

    enable-cache            services        yes
    positive-time-to-live   services        28800
    negative-time-to-live   services        20
    suggested-size          services        211
    check-files             services        yes
    persistent              services        yes
    shared                  services        yes
    max-db-size             services        33554432

的resolv.conf

# Generated by dhcpcd from eth0
nameserver 127.0.0.1
domain westell.com
nameserver 192.168.1.1
nameserver 208.67.222.222
nameserver 208.67.220.220

作为一个侧面说明我正在使用Arch Linux.

注意:这已被移动了两次,我从来没有弄清楚为什么应用程序,不包括挖掘,没有达到nscd缓存,浏览器,IM,IRC,都应该是,但他们没有

解决方法:

您丢失缓存命中的原因是dig直接查询DNS.您可以尝试查看缓存是否与getent命令一起使用:

getent hosts host.example.com

运行单独的缓存DNS是个好主意,但是如果可能的话,您应该考虑在网络级别运行它.如果每个主机分别缓存数据,它们仍将为同一主机运行多个查询.单缓存解决此问题.

Nscd本身是NSS功能的缓存守护进程.所以焦点与本机缓存名称服务器有点不同.因此,如果您只想要一个缓存名称服务器,请使用除nscd之外的其他内容.如果您希望在正常DNS系统之外缓存共享用户名和主机数据之类的内容,请转到nscd.

为了记录,我已经非常喜欢powerdns resolver(pdns-resolver).


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

相关教程推荐

其他课程推荐