본문 바로가기

네임서버

우분투 24.04에서 BIND9를 설치하는 방법

반응형

우분투 24.04에서 BIND9를 설치하는 방법

테스트 환경

운영체제 정보

$ lsb_release -d
Description:    Ubuntu 24.04.3 LTS

1. BIND9 설치

패키지 목록 업데이트

sudo apt update

BIND9 설치

sudo apt install -y bind9 bind9-utils dnsutils

버전 확인

named -v
BIND 9.18.39-0ubuntu0.24.04.2-Ubuntu (Extended Support Version) <id:>
  • 우분투 24.04에서도 9.18 ESV가 기본이며 장기 운영에 안정적인 선택입니다.

2. BIND9 기본 설정 구조

/etc/bind/named.conf : 메인 설정 파일

/etc/bind/named.conf.options : 캐시/리졸버 동작 설정

3. 메인 설정 파일 확인

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

4. 캐시 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;
    
    // 재귀 제한
    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";

        // If there is a firewall between you and nameservers you want
        // to talk to, you may need to fix the firewall to allow multiple
        // ports to talk.  See http://www.kb.cert.org/vuls/id/800113

        // If your ISP provided one or more IP addresses for stable
        // nameservers, you probably want to use them as forwarders.
        // Uncomment the following block, and insert the addresses replacing
        // the all-0's placeholder.

        // forwarders {
        //      0.0.0.0;
        // };

        //========================================================================
        // If BIND logs error messages about the root key being expired,
        // you will need to update your keys.  See https://www.isc.org/bind-keys
        //========================================================================
        dnssec-validation auto;

        listen-on-v6 { any; };
};
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에서는 불필요(명시 안 함)

쿼리 로깅 활성화

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

로그 디렉터리 생성

sudo mkdir -p /var/log/named
sudo chown bind:bind /var/log/named
sudo chmod 755 /var/log/named

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

sudo tee /etc/bind/named.logging.conf > /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.logging.conf
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; };
};

---

named.conf에 포함

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

---

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

---

설정 파일 검증

전체 설정 검사

sudo named-checkconf

BIND9 서비스 시작

서비스 활성화 및 시작

sudo systemctl enable --now named

상태 확인

sudo systemctl status named

캐시 DNS 동작 테스트

로컬 테스트

dig @127.0.0.1 google.com

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

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

 

728x90
반응형