우분투에서 DNS 서버(BIND9)를 설치하는 방법
1. DNS 서버(BIND9) 설치
sudo apt updatesudo apt install -y bind9 bind9-utils bind9-dnsutils서비스 활성화 및 시작
sudo systemctl enable --now named버전 확인
named -v주요 패키지
- bind9 : DNS 서버 데몬
- bind9-utils : named-checkconf, named-checkzone 등 유틸리티
- dnsutils : dig, nslookup 명령어
2. BIND 9 기본 설정 파일 구조
우분투 24.04의 BIND9 설정 파일
/etc/bind/
├── named.conf
├── named.conf.options
├── named.conf.local
├── named.conf.default-zones
└── db.*주요 파일 역할
- named.conf : 메인 설정 파일 (다른 파일 포함)
- named.conf.options : 글로벌 옵션
- named.conf.local : 사용자 정의 존(zone)
- named.conf.default-zones : 기본 로컬 존
- db.* : DNS 존 데이터
메인 설정 파일
sudo vim /etc/bind/named.conf// This is the primary configuration file for the BIND DNS server named.
//
// Please read /usr/share/doc/bind9/README.Debian for information on the
// structure of BIND configuration files in Debian, *BEFORE* you customize
// this configuration file.
//
// If you are just adding zones, please do that in /etc/bind/named.conf.local
include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";
include "/etc/bind/named.logging.conf";기본 옵션 설정 파일
sudo vim /etc/bind/named.conf.optionsoptions {
directory "/var/cache/bind";
listen-on { any; };
listen-on-v6 { any; };
allow-query { any; };
recursion yes;
allow-recursion { any; };
// 외부 DNS Forwarder
forwarders {
8.8.8.8;
8.8.4.4;
};
// 보안 권장 옵션
dnssec-validation auto;
auth-nxdomain no;
// 불필요한 정보 최소화
version "not currently available";
};로그 설정 파일 생성
sudo vim /etc/bind/named.logging.conflogging {
channel general_log {
file "/var/log/named/general.log" versions 3 size 20m;
severity notice;
print-time yes;
print-severity yes;
print-category yes;
};
channel query_log {
file "/var/log/named/queries.log" versions 5 size 50m;
severity info;
print-time yes;
print-severity yes;
print-category yes;
};
channel security_log {
file "/var/log/named/security.log" versions 3 size 20m;
severity warning;
print-time yes;
print-severity yes;
print-category yes;
};
category queries { query_log; };
category general { general_log; };
category security { security_log; };
};로그 디렉토리 생성
sudo mkdir -p /var/log/named
sudo chown bind:bind /var/log/named
sudo chmod 755 /var/log/named3. 설정 파일 문법 검사
sudo named-checkconf4. DNS 서버(BIND9) 재시작
sudo systemctl restart named5. DNS 동작 테스트
dig 사용
dig @127.0.0.1 google.comnslookup 사용
nslookup google.com 127.0.0.1참고URL
- ubuntu manuals : noble named
- Download ISC’s open source software : BIND 9.20