본문 바로가기

네임서버

우분투 24.04에서 최신 버전의 BIND9를 설치하는 방법

반응형

우분투 24.04에서 최신 버전의 BIND9를 설치하는 방법

테스트 환경

운영체제 정보

$ lsb_release -d
Description:    Ubuntu 24.04.3 LTS

1. 시스템 업데이트 및 필수 패키지 설치

시스템을 최신 상태로 업데이트하고 PPA 관리에 필요한 도구를 설치합니다.

sudo apt update && sudo apt upgrade -y
sudo apt install -y software-properties-common

2. ISC 공식 PPA 저장소 추가

우분투 기본 저장소의 BIND는 버전(BIND 9.18.39)이 낮을 수 있으므로 최신 안정화 버전을 제공하는 ISC의 공식 PPA를 추가합니다.

sudo add-apt-repository -y ppa:isc/bind
sudo apt update

3. BIND9 설치

최신 버전의 BIND9와 유틸리티를 설치합니다.

sudo apt install -y bind9 bind9-utils bind9-doc dnsutils

버전 확인

named -v
BIND 9.20.22-1+ubuntu24.04.1+deb.sury.org+1-Ubuntu (Stable Release) <id:>

4. 방화벽 설정 (UFW) - 선택 사항

DNS 서버는 UDP/TCP 53번 포트를 사용합니다.

방화벽이 활성화되어 있다면 외부 통신을 위해 해당 포트를 열어주어야 합니다.

# DNS 관련 포트 허용
sudo ufw allow Bind9

# 또는 포트 번호로 직접 허용
sudo ufw allow 53/tcp
sudo ufw allow 53/udp

# 방화벽 상태 확인
sudo ufw status

5. BIND9 기본 설정 구조

BIND9의 설정 파일들은 /etc/bind/ 디렉토리에 위치합니다.

  • /etc/bind/named.conf : 메인 설정 파일
  • /etc/bind/named.conf.options : DNS 쿼리 제한(ACL), 포워딩, 보안 설정 등 전역 옵션
  • /etc/bind/named.conf.local : 로컬 존(Zone) 정의 (도메인 설정)
  • /etc/bind/named.conf.root-hints : 루트 네임서버

6. 메인 설정 파일 확인

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.root-hints";
캐시 DNS 전용이라면
named.conf.local에는 아무 존(Zone)도 정의하지 않는 것이 정석입니다.

7. 캐시 DNS 설정(named.conf.options)

sudo tee /etc/bind/named.conf.options > /dev/null << 'EOF'
options {
    // 기본
    directory "/var/cache/bind";
    
    // 네트워크
    listen-on { any; };
    listen-on-v6 { any; };
    
    // 보안
    allow-query { any; };
    allow-transfer { none; };
    allow-update { none; };
    
    recursion yes;
    
    empty-zones-enable no;
    
    // 재귀 제한
    allow-recursion {
        localhost;
        192.168.0.0/16;
        10.0.0.0/8;
    };
    
    // 포워딩
    forwarders {
        8.8.8.8;
        8.8.4.4;
    };
    
    // DNSSEC
    dnssec-validation auto;
    
    // 정보 은닉
    version none;
};
EOF
더보기

---

cat /etc/bind/named.conf.options
options {
	directory "/var/cache/bind";
};
sudo vim /etc/bind/named.conf.options
options {
        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";
};

---

  • recursion yes; → 캐시 DNS의 핵심
  • forwarders → Google / Cloudflare / 내부 상위 DNS 사용 가능
  • allow-transfer/allow-update → 캐시 DNS에서는 불필요(명시 안 함)

8. 쿼리 로깅 활성화

캐시 DNS 운영 시 queries 로그만 있어도 충분합니다.

 

로그 디렉터리 생성

sudo mkdir -p /etc/bind/log
sudo ln -sf /etc/bind/log /var/log/named
sudo chown bind:bind /etc/bind/log /var/log/named
sudo chmod 775 /etc/bind/log

간결한 로깅 설정(named.conf.logging)

sudo tee /etc/bind/named.conf.logging > /dev/null << 'EOF'
logging {
        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; };
};
EOF
더보기

---

sudo vim /etc/bind/named.conf.logging
logging {
        channel general_log {
                file "/etc/bind/log/general.log" versions 3 size 20m;
                severity notice;
                print-time yes;
                print-severity yes;
                print-category yes;
        };
        channel query_log {
                file "/etc/bind/log/queries.log" versions 5 size 50m;
                severity info;
                print-time yes;
                print-severity yes;
                print-category yes;
        };
        channel security_log {
                file "/etc/bind/log/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; };
};

---

AppArmor 설정

우분투의 보안 모듈인 AppArmor가 BIND의 로그 기록을 차단할 수 있습니다.

sudo tee /etc/apparmor.d/local/usr.sbin.named > /dev/null << 'EOF'
/etc/bind/zones/** rw,
/var/cache/bind/** rw,
/etc/bind/log/** rw,
/etc/bind/data/** rw,
EOF

AppArmor 재시작

sudo systemctl restart apparmor

named.conf.logging 파일을 named.conf에 포함

echo 'include "/etc/bind/named.conf.logging";' | sudo tee -a /etc/bind/named.conf
더보기

---

sudo vim /etc/bind/named.conf.options
include "/etc/bind/named.logging.conf";

---

설정 파일 검증

전체 설정 검사

sudo named-checkconf

9. BIND9 서비스 시작

서비스 활성화 및 시작

sudo systemctl enable --now named

상태 확인

sudo systemctl status named

10. 캐시 DNS 동작 테스트

로컬 테스트

dig @127.0.0.1 google.com

캐시 확인(두 번 연속 실행)

dig @127.0.0.1 google.com
dig @127.0.0.1 google.com

 

참고URL

- BIND 9 Documentation : BIND Logging

 

728x90
반응형