DNS 캐시 · 2 min read · Oct 03, 2025
djbdns로 DNS 캐시 만들기
djbdns로 DNS 캐시 만들기
로컬 DNS 캐시를 구축하면 인터넷 연결 속도가 빨라집니다. 이는 “변환 작업”(도메인 이름을 IP 주소로 변환하는 데 걸리는 시간)이 무시할 수 있을 정도로 짧아지기 때문입니다. DNS 캐시가 부모 DNS에서 정보를 가져온다고 가정합니다.
FreeBSD는 각 릴리스에 bind를 포함하고 있지만, 저는 djbdns를 사용하는 것을 선호합니다.
FreeBSD에서 포트를 사용하여 로컬 DNS 캐시를 구축하는 간단한 방법:
1. djbdns 포트 설치
su-2.05b# whereis djbdns
djbdns: /usr/ports/dns/djbdns
su-2.05b# cd /usr/ports/dns/djbdns && make install cleanOK를 누르면 설치 프로세스가 시작됩니다.
2. 구성
# pw groupadd nofiles -g 800
# pw useradd dnslog -g nofiles -u 810 -d /nonexistent -s /sbin/nologin
# pw useradd dnscache -g nofiles -u 811 -d /nonexistent -s /sbin/nologin이 명령은 nofiles 그룹과 dnslog 및 dnscache 사용자를 추가합니다.
# dnscache-conf dnscache dnslog /etc/dnscache 127.0.0.1
# ln -s /etc/dnscache /var/service
# echo ‘nameserver 127.0.0.1? >/etc/resolv.conf이 명령은 IP 주소 127.0.0.1을 해당 컴퓨터에 대한 DNS 캐시 “전용”으로 만듭니다.
우리 네트워크에서 DNS 캐시를 사용하려면 더 많은 명령을 발행해야 합니다:
# dnscache-conf dnscache dnslog /etc/dnscache 192.168.1.1
# touch /etc/dnscache/root/ip/192.168.1
# ln -s /etc/dnscache /var/service이제 각 클라이언트는 192.168.1.1을 유효한 DNS 해석기로 추가할 수 있습니다:
“daemontools”의 기능을 사용하려면 rc.conf에 이 항목을 추가해야 합니다:
svscan_enable="YES"처음에는 수동으로 시작해야 합니다:
su-2.05b# /usr/local/etc/rc.d/svscan.sh start실행 중인 서비스를 확인합니다:
su-2.05b# ps -ax | grep dns338 ?? I 0:00.03 supervise dnscache
90515 ?? S 0:03.51 /usr/local/bin/dnscachednscache가 “정말로 작동하는지“ 확인하려면:
su-2.05b# tail -f /etc/dnscache/log/main/current예시 출력:
su-2.05b# tail -f /etc/dnscache/log/main/current
@4000000046375a22168f3ee4 cached 1 i.gtld-servers.net.
@4000000046375a22168fcf6c cached 1 j.gtld-servers.net.
@4000000046375a2216905ff4 cached 1 k.gtld-servers.net.
@4000000046375a221690ec94 cached 1 l.gtld-servers.net.
@4000000046375a2216917d1c cached 1 m.gtld-servers.net.
@4000000046375a22169209bc cached 1 a.gtld-servers.net.
@4000000046375a221692c154 cached 1 b.gtld-servers.net.
@4000000046375a22169351dc cached 1 c.gtld-servers.net.
@4000000046375a221693de7c cached 1 d.gtld-servers.net.
@4000000046375a2216945794 tx 0 255 mx44.alanistz.com. com. c005061e c0304f1e c036701e c023331e c037531e c02a5d1e c01a5c1e c0210e1e c029a21e c00c5e1e c02bac1e c01f501e c034b21e
@4000000046375a222673d964 rr cc4a7021 86400 1 mx74mi.clarmu.info. d035034a
@4000000046375a2226787514 rr cc4a7021 86400 1 mx144pb.clarmu.info. 42212090
@4000000046375a222678889c rr cc4a7021 86400 1 mx174hi.clarmu.info. 42f890ae
@4000000046375a222678983c rr cc4a7021 86400 1 mx187tr.clarmu.info. 416f11bb
@4000000046375a222678abc4 rr cc4a7021 86400 1 mx204pa.clarmu.info. 42217dcc
@4000000046375a222678bb64 rr cc4a7021 86400 ns clarmu.info. mx74mi.clarmu.info.
@4000000046375a222678ceec rr cc4a7021 86400 ns clarmu.info. mx204pa.clarmu.info.
@4000000046375a222678de8c rr cc4a7021 86400 ns clarmu.info. mx187tr.clarmu.info.
@4000000046375a222679059c rr cc4a7021 86400 ns clarmu.info. mx174hi.clarmu.info.
@4000000046375a222679153c rr cc4a7021 86400 ns clarmu.info. mx144pb.clarmu.info.
@4000000046375a22267924dc stats 379 144625 13 0
@4000000046375a2226793864 cached 1 mx74mi.clarmu.info.
@4000000046375a2226794804 cached 1 mx204pa.clarmu.info.
@4000000046375a22267957a4 cached 1 mx187tr.clarmu.info.
@4000000046375a2226796744 cached 1 mx174hi.clarmu.info축하합니다. DNS 캐시가 잘 작동하고 있습니다.
새 게시물을 받은 편지함에서 받기
스팸은 없습니다. 언제든지 구독 해지 가능합니다.