Byeon-gun's WIPI

IT 인프라와 소프트웨어 개발에 관한 실용적인 기술 가이드와 튜토리얼을 제공하는 기술 블로그입니다.

Byeon-gun's WIPI

IT 인프라와 소프트웨어 개발에 관한 실용적인 기술 가이드와 튜토리얼을 제공하는 기술 블로그입니다.

우분투에서 DNS 서버(BIND9)를 설치하는 방법

1. DNS 서버(BIND9) 설치

sudo apt update
sudo 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.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";
};

로그 설정 파일 생성

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; };
};

로그 디렉토리 생성

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

3. 설정 파일 문법 검사

sudo named-checkconf

4. DNS 서버(BIND9) 재시작

sudo systemctl restart named

5. DNS 동작 테스트

dig 사용

dig @127.0.0.1 google.com

nslookup 사용

nslookup google.com 127.0.0.1

참고URL

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

Scroll to top