DNS 쿼리는 nscd를 사용하여 캐시되지 않습니다.

DNS 쿼리는 nscd를 사용하여 캐시되지 않습니다.

저는 Bind 사용을 중지할 수 있도록 nscd(이름 서비스 캐시 데몬)를 사용하여 DNS를 로컬로 캐시하려고 합니다. 시작했는데 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

구성 파일 구문 분석

# 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를 사용하고 있습니다.

참고: 이것은 두 번 이동되었으며 애플리케이션(dig 제외)이 nscd 캐시, 브라우저, IM, IRC에 도달하지 않는 이유를 결코 파악하지 못했습니다. 모두 있어야 하지만 그렇지 않습니다.

답변1

캐시 적중이 누락되는 이유는 dig가 DNS를 직접 쿼리하기 때문입니다. 캐시가 작동하는지 확인하려면 다음 명령을 시도해 보세요 getent.

getent hosts host.example.com

별도의 캐시된 DNS를 실행하는 것이 좋지만 가능하면 네트워크 수준에서 실행하는 것을 고려해야 합니다. 각 호스트가 데이터를 개별적으로 캐시하는 경우에도 동일한 호스트에 대해 여러 쿼리를 실행합니다. 단일 캐시로 이 문제를 해결할 수 있습니다.

Nscd 자체는 NSS 기능을 위한 캐시 데몬입니다. 따라서 초점은 기본 캐싱 이름 서버와 약간 다릅니다. 따라서 캐싱 네임서버만 원한다면 nscd가 아닌 다른 것을 사용하세요. 반대로 일반 DNS 시스템 외부에서 공유 사용자 이름 및 호스트 데이터와 같은 항목을 캐시하려면 nscd를 사용하십시오.

참고로 저는 powerdns 리졸버(pdns-resolver)를 정말 좋아합니다.

답변2

nscd.conf에 호스트 구성이 누락되었습니다. 내 것을 예로 들어 보겠습니다.

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

이것은 뭔가를 깨뜨릴 것입니다. 다음 정보는 Debian 패키지에서 가져온 것입니다:

  Since this release, hosts caching in nscd is off by default: for some of the
  libc calls (gethostby* calls) nscd does not respect the DNS TTLs.  It can
  lead to system lockups (e.g. if you are using pam-ldap and change the IP of
  your authentication server) hence is not considered safe.

  See debian bug #335476 and how upstream answered to that in
  http://sourceware.org/bugzilla/show_bug.cgi?id=4428.

 -- Pierre Habouzit <[email protected]>  Sat, 28 Apr 2007 11:10:56 +0200

답변3

나는 nscd에 대해 잘 모릅니다. DNS 조회에 문제가 자주 발생하고 항상 nscd(또는 적어도 호스트 조회 부분)를 비활성화한다는 점을 제외하면 말이죠. Nscd를 사용하면 TTL(time-to-live) 값을 설정할 수 있으며 DNS는 이러한 값을 "소유"하고 모든 확인자가 이를 존중하도록 기대한다는 것을 알고 있습니다. DNS에서 TTL을 준수하지 않으면 이상한 결과가 발생할 수 있습니다. 내 제안은 nscd를 사용하여 DNS를 캐시하지 않는 것입니다. 로컬 컴퓨터에서 이미 캐싱 이름 서버가 실행 중인 것 같으므로 DNS 조회를 두 번 캐시할 필요가 없습니다.

답변4

지옥에 DNS 캐시가 있다면 nscd에서 제공할 것입니다. 아니요. 사용. 그것.

단지 다르기 위해서:데이터 센터실제로 매우 좋은 대안입니다. 또는 unscd(적어도 openSUSE의 기본값)입니다.

관련 정보