BIND 소개와 설치 가이드
BIND 9 DNS 서버 설치와 설정 가이드입니다. authoritative zone, recursion 제한, zone file, named-checkconf, named-checkzone, dig, rndc와 open resolver 주의사항을 정리했습니다.
BIND 9는 DNS 서버 구현체입니다. authoritative DNS 서버로 도메인 존을 직접 제공할 수도 있고, 내부 resolver/cache 서버로 사용할 수도 있습니다. 두 역할은 보안 설정이 다르므로 “일단 설치 후 recursion 허용”처럼 운영하면 open resolver가 되어 악용될 수 있습니다.
설치
# Ubuntu/Debian
sudo apt update
sudo apt install -y bind9 bind9-utils dnsutils
# RHEL/Rocky/Alma
sudo dnf install -y bind bind-utils
설정 파일 구조
BIND 9 공식 문서는 기본 구성 파일을 named.conf로 설명합니다. 배포판별 경로는 다를 수 있습니다.
# Ubuntu/Debian
/etc/bind/named.conf
/etc/bind/named.conf.options
/etc/bind/named.conf.local
# RHEL 계열
/etc/named.conf
/var/named/
authoritative zone 예시
외부에 example.com 존을 제공하는 예시입니다. public authoritative 서버라면 recursion을 제한해야 합니다.
options {
directory "/var/cache/bind";
recursion no;
allow-query { any; };
listen-on { any; };
listen-on-v6 { any; };
};
zone "example.com" {
type master;
file "/etc/bind/zones/db.example.com";
allow-transfer { none; };
};
존 파일 디렉터리를 만들고 파일을 작성합니다.
sudo install -d -m 755 /etc/bind/zones
sudo tee /etc/bind/zones/db.example.com >/dev/null <<'EOF'
$TTL 300
@ IN SOA ns1.example.com. admin.example.com. (
2026062301 ; serial
3600 ; refresh
900 ; retry
1209600 ; expire
300 ; negative cache ttl
)
IN NS ns1.example.com.
ns1 IN A 192.0.2.10
www IN A 192.0.2.20
EOF
문법 검사
BIND는 설정/존 문법 검사를 반드시 거친 뒤 reload합니다.
sudo named-checkconf
sudo named-checkzone example.com /etc/bind/zones/db.example.com
sudo systemctl reload bind9 2>/dev/null || sudo systemctl reload named
서비스 확인
sudo systemctl status bind9 --no-pager 2>/dev/null || sudo systemctl status named --no-pager
sudo ss -lunpt | grep ':53'
dig @127.0.0.1 example.com SOA
dig @127.0.0.1 www.example.com A
내부 resolver로 쓸 때
내부망 resolver/cache로 쓸 때는 recursion을 허용하되 대상 대역을 제한합니다.
acl internal_lan {
192.168.10.0/24;
127.0.0.1;
};
options {
recursion yes;
allow-recursion { internal_lan; };
allow-query { internal_lan; };
forwarders { 1.1.1.1; 8.8.8.8; };
};
로그와 문제 해결
journalctl -u bind9 -n 100 --no-pager 2>/dev/null || journalctl -u named -n 100 --no-pager
dig @server.example.com example.com NS
dig +trace example.com
rndc status
rndc reload
SOA serial을 올리지 않으면 secondary나 캐시가 변경을 알아차리지 못할 수 있습니다. 존 파일을 수정할 때마다 serial을 증가시키는 습관을 들이세요.