BIND

Contents

BINDについて


公式ページ:https://www.isc.org/downloads/bind/

用語


コンテンツサーバ


自サイトのドメインを管理し、問い合わせに対して応答するサーバ

キャッシングサーバ


自サイトのクライアントの代理としてドメイン名の解決をするサーバ。
解決結果はキャッシュされることからこの名前で呼ばれる。
フォワーディングサーバやフルサービスリゾルバとも呼ばれることがある。

フォワーディングサーバ


ドメイン名の解決をするが、一定の場合は問い合わせを転送して結果を問い合わせ元に返すキャッシングサーバのこと。

フルサービスリゾルバ


問い合わせを転送することなく、単独で全てのドメイン名の問い合わせを行うことができるキャッシングサーバのこと。

機能


RNDCユーティリティ




サーバー構築


構築環境




OS設定


ネットワーク


固定IPアドレス割り当て


次のファイルを編集する
# ifcfg-loはループバックインタフェースであるため、触らない
vi /etc/sysconfig/network-scripts/ifcfg-<インタフェース名>

以下では例として192.168.0.51/24を割り当てた
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.0.51
NETMASK=255.255.255.0
NETWORK=192.168.0.0
GATEWAY=192.168.0.1

ネットワークを再起動する
systemctl restart network

ip addressコマンドにより、インタフェースが有効になっていることを確認する
これによりホストマシンなどからSSHでログイン可能となる


firewalld


DNS

DNS(TCP/53、UDP/53)を開ける場合、下記を行う。
※CentOS7.2以前のCentOS7場合はfirewalldのバージョン場古く、下記を実行できない。アップデートすること。
yum update firewalld -y

  1. ルールが定義されていることを確認
    firewall-cmd --permanent --info-service=dns
  2. 現在ルールが適用されていないことを確認する
    firewall-cmd --list-services --zone=public --permanent | sed -e "s/ /\n/g" | grep dns
  3. ルールを適用する
    firewall-cmd --add-service=dns --zone=public --permanent
  4. ルールが適用されていることを確認する
    firewall-cmd --list-services --zone=public --permanent | sed -e "s/ /\n/g" | grep dns
  5. firewalldシステムを再起動して設定を反映させる
    systemctl restart firewalld

RNDC

BINDのリモート管理用のポート(TCP/953)を開ける場合、下記を行う。
ローカルからのみ管理する場合は不要である。

  1. 現在ルールが定義されていないか確認
    firewall-cmd --permanent --info-service=rndc
  2. 新しいルールを定義
    firewall-cmd --new-service=rndc --permanent
    firewall-cmd --service=rndc --add-port=953/tcp --permanent
  3. ルールが定義されていることを確認
    firewall-cmd --permanent --info-service=rndc
  4. 現在ルールが適用されていないことを確認する
    firewall-cmd --list-services --zone=public --permanent | sed -e "s/ /\n/g" | grep rndc
  5. ルールを適用する
    firewall-cmd --add-service=rndc --zone=public --permanent
  6. ルールが適用されていることを確認する
    firewall-cmd --list-services --zone=public --permanent | sed -e "s/ /\n/g" | grep rndc
  7. 設定を再読み込みして反映させる
    firewall-cmd --reload

ホスト名


ホスト名としてdnsを設定する
hostname dns.corp
# 再起動しても有効にする
echo dns.corp > /etc/hostname
再ログインすることで有効になる。

ユーザ作成


BIND用のユーザを作成する
useradd --user-group --no-create-home --shell /sbin/false bind

関連ソフトウェアのインストール


OpenSSL


wget http://www.openssl.org/source/openssl-1.0.0d.tar.gz
tar xzvf openssl-1.0.0d.tar.gz
cd openssl-*
./config --prefix=/usr/local/`pwd | sed "s/.*\///"` --openssldir=/usr/local/`pwd | sed "s/.*\///"` -fPIC
make
make install
cd ../

BINDの構築


インストールに関するドキュメント:https://ftp.isc.org/isc/bind9/cur/9.9/doc/arm/Bv9ARM.ch12.html#id-1.13.2.6

BINDのインストール


パッケージからインストール


[root@dns ~]# yum install bind -y
Loaded plugins: fastestmirror
base                                                                                                  | 3.6 kB  00:00:00
extras                                                                                                | 3.4 kB  00:00:00
packages-microsoft-com-mssql-server-2017                                                              | 2.9 kB  00:00:00
packages-microsoft-com-prod                                                                           | 2.9 kB  00:00:00
updates                                                                                               | 3.4 kB  00:00:00
(1/4): extras/7/x86_64/primary_db                                                                     | 181 kB  00:00:00
(2/4): packages-microsoft-com-mssql-server-2017/primary_db                                            | 9.9 kB  00:00:00
(3/4): packages-microsoft-com-prod/primary_db                                                         |  69 kB  00:00:00
(4/4): updates/7/x86_64/primary_db                                                                    | 6.9 MB  00:00:01
Determining fastest mirrors
 * base: centos.usonyx.net
 * extras: ftp.iij.ad.jp
 * updates: centos.usonyx.net
Resolving Dependencies
--> Running transaction check
---> Package bind.x86_64 32:9.9.4-51.el7_4.2 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================== =======================
= Package Arch Version Repositor Size
y===================================================================================================== =======================
=Installing:
 bind                    x86_64                    32:9.9.4-51.el7_4.2                      updates                    1.8 M

Transaction Summary
===================================================================================================== =======================
=Install 1 Package
Total download size: 1.8 M
Installed size: 4.3 M
Downloading packages:
bind-9.9.4-51.el7_4.2.x86_64.rpm                                                                      | 1.8 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 32:bind-9.9.4-51.el7_4.2.x86_64                                                                           1/1
  Verifying  : 32:bind-9.9.4-51.el7_4.2.x86_64                                                                           1/1

Installed:
  bind.x86_64 32:9.9.4-51.el7_4.2

Complete!

ソースコードからインストール


  1. rootになる
    su -
  2. 関連パッケージをインストールする
    まとめてインストールする場合
    yum install gcc openssl-devel -y
    1. コンパイラをインストールする
      yum install gcc -y
    2. opensslのビルドセットをインストールする
      yum install openssl-devel -y
  3. ソースコードを取得する
    1. ダウンロードサイト:https://www.isc.org/downloads/からBINDの「Current-Stable」版のアーカイブのURLを取得する
    2. ダウンロードする
      curl -O -s https://www.isc.org/downloads/file/bind-9-11-3/?version=tar-gz
    3. ダウンロードしたファイルをリネームする
      mv \?version\=tar-gz bind-9.11.3.tar.gz
    4. アーカイブファイルを展開する
      tar xzfv bind-*.tar.gz
    5. ソースコードディレクトリへ移動する
      cd bind-*
  4. コンパイル、インストールを行う
    1. コンパイル最適化設定を行う
      export CFLAGS="-O3 -m64"
    2. Makefileを生成する
      ./configure --prefix=/usr/local/`pwd | sed "s/.*\///"` --oldincludedir=/usr/local/`pwd | sed "s/.*\///"`/include --without-openssl 2>&1 | tee configure.log
      • オプション一覧

        [root@dns bind-9.11.3]# ./configure --help
        `configure' configures BIND 9.11 to adapt to many kinds of systems.
        
        Usage: ./configure [OPTION]... [VAR=VALUE]...
        
        To assign environment variables (e.g., CC, CFLAGS...), specify them as
        VAR=VALUE.  See below for descriptions of some of the useful variables.
        
        Defaults for the options are specified in brackets.
        
        Configuration:
          -h, --help              display this help and exit
              --help=short        display options specific to this package
              --help=recursive    display the short help of all the included packages
          -V, --version           display version information and exit
          -q, --quiet, --silent   do not print `checking ...' messages
              --cache-file=FILE   cache test results in FILE [disabled]
          -C, --config-cache      alias for `--cache-file=config.cache'
          -n, --no-create         do not create output files
              --srcdir=DIR        find the sources in DIR [configure dir or `..']
        
        Installation directories:
          --prefix=PREFIX         install architecture-independent files in PREFIX
                                  [/usr/local]
          --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                                  [PREFIX]
        
        By default, `make install' will install all the files in
        `/usr/local/bin', `/usr/local/lib' etc.  You can specify
        an installation prefix other than `/usr/local' using `--prefix',
        for instance `--prefix=$HOME'.
        
        For better control, use the options below.
        
        Fine tuning of the installation directories:
          --bindir=DIR            user executables [EPREFIX/bin]
          --sbindir=DIR           system admin executables [EPREFIX/sbin]
          --libexecdir=DIR        program executables [EPREFIX/libexec]
          --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
          --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
          --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
          --libdir=DIR            object code libraries [EPREFIX/lib]
          --includedir=DIR        C header files [PREFIX/include]
          --oldincludedir=DIR     C header files for non-gcc [/usr/include]
          --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
          --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
          --infodir=DIR           info documentation [DATAROOTDIR/info]
          --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
          --mandir=DIR            man documentation [DATAROOTDIR/man]
          --docdir=DIR            documentation root [DATAROOTDIR/doc/bind]
          --htmldir=DIR           html documentation [DOCDIR]
          --dvidir=DIR            dvi documentation [DOCDIR]
          --pdfdir=DIR            pdf documentation [DOCDIR]
          --psdir=DIR             ps documentation [DOCDIR]
        
          NOTE: If PREFIX is not set, then the default values for --sysconfdir
          and --localstatedir are /etc and /var, respectively.
        
        System types:
          --build=BUILD     configure for building on BUILD [guessed]
          --host=HOST       cross-compile to build programs to run on HOST [BUILD]
        
        Optional Features:
          --disable-option-checking  ignore unrecognized --enable/--with options
          --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
          --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
          --enable-shared[=PKGS]  build shared libraries [default=yes]
          --enable-static[=PKGS]  build static libraries [default=yes]
          --enable-fast-install[=PKGS]
                                  optimize for fast installation [default=yes]
          --disable-libtool-lock  avoid locking (might break parallel builds)
          --enable-libbind        deprecated
          --enable-buffer-useinline
                                  define ISC_BUFFER_USEINLINE when compiling
                                  [[default=yes]]
          --enable-warn-shadow    turn on -Wshadow when compiling
          --enable-warn-error     turn on -Werror when compiling
          --enable-developer      enable developer build settings
          --enable-afl            enable American Fuzzy Lop test harness [default=no]
          --enable-seccomp        enable support for libseccomp system call filtering
                                  [default=no]
          --enable-kqueue         use BSD kqueue when available [default=yes]
          --enable-epoll          use Linux epoll when available [default=auto]
          --enable-devpoll        use /dev/poll when available [default=yes]
          --enable-threads        enable multithreading
          --enable-native-pkcs11  use native PKCS11 for all crypto [default=no]
          --enable-openssl-hash   use OpenSSL for hash functions [default=no]
          --enable-openssl-version-check
                                  check OpenSSL version [default=yes]
          --enable-largefile      64-bit file support
          --enable-backtrace      log stack backtrace on abort [default=yes]
          --enable-symtable       use internal symbol table for backtrace
                                  [all|minimal(default)|none]
          --enable-ipv6           use IPv6 [default=autodetect]
          --disable-tcp-fastopen  disable TCP Fast Open support [default=autodetect]
          --enable-getifaddrs     enable the use of getifaddrs() [yes|no].
          --disable-isc-spnego    use SPNEGO from GSSAPI library
          --disable-chroot        disable chroot
          --disable-linux-caps    disable linux capabilities
          --enable-atomic         enable machine specific atomic operations
                                  [default=autodetect]
          --enable-fixed-rrset    enable fixed rrset ordering [default=no]
          --disable-rpz-nsip      disable rpz nsip rules [default=enabled]
          --disable-rpz-nsdname   disable rpz nsdname rules [default=enabled]
          --enable-filter-aaaa    enable filtering of AAAA records [default=no]
          --enable-dnstap         enable dnstap support (requires fstrm, protobuf-c)
          --enable-querytrace     enable very verbose query trace logging [default=no]
          --enable-full-report    report values of all configure options
        
        Optional Packages:
          --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
          --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
          --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
                                  both]
          --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
          --with-sysroot=DIR Search for dependent libraries within DIR
                                (or the compiler's sysroot if not specified).
          --with-python=PATH      specify path to python interpreter
          --with-python-install-dir=PATH
                                  installation directory for Python modules
          --with-geoip=PATH       Build with GeoIP support (yes|no|path)
          --with-gssapi=PATH|/path/krb5-config
                                  Specify path for system-supplied GSSAPI
                                  [default=yes]
          --with-randomdev=PATH   Specify path for random device
          --with-locktype=ARG     Specify mutex lock type (adaptive or standard)
          --with-libtool          use GNU libtool
          --with-openssl=PATH     Build with OpenSSL [yes|no|path]. (Crypto is
                                  required for DNSSEC)
          --with-pkcs11=PATH      Build with PKCS11 support [yes|no|path] (PATH is for
                                  the PKCS11 provider)
          --with-ecdsa            Crypto ECDSA
          --with-gost             Crypto GOST [yes|no|raw|asn1].
          --with-eddsa            Crypto EDDSA [yes|all|no].
          --with-aes              Crypto AES
          --with-cc-alg=ALG       choose the algorithm for Client Cookie
                                  [aes|sha1|sha256]
          --with-lmdb=PATH        build with LMDB library [yes|no|path]
          --with-libxml2=PATH     build with libxml2 library [yes|no|path]
          --with-libjson=PATH     build with libjson0 library [yes|no|path]
          --with-zlib=PATH        build with zlib for HTTP compression [default=yes]
          --with-purify=PATH      use Rational purify
          --with-gperftools-profiler
                                  use gperftools CPU profiler
          --with-kame=PATH        use Kame IPv6 [default path /usr/local/v6]
          --with-readline=LIBSPEC specify readline library [default auto]
        
          --with-protobuf-c=path  Path where protobuf-c is installed, for dnstap
          --with-libfstrm=path    Path where libfstrm is installed, for dnstap
          --with-docbook-xsl=PATH specify path for Docbook-XSL stylesheets
          --with-idn=MPREFIX      enable IDN support using idnkit [default PREFIX]
          --with-libiconv=IPREFIX GNU libiconv are in IPREFIX [default PREFIX]
          --with-iconv=LIBSPEC    specify iconv library [default -liconv]
          --with-idnlib=ARG       specify libidnkit
          --with-atf              support Automated Test Framework
          --with-tuning=ARG       Specify server tuning (large or default)
          --with-dlopen=ARG       support dynamically loadable DLZ drivers
          --with-dlz-postgres=PATH
                                  Build with Postgres DLZ driver [yes|no|path].
                                  (Required to use Postgres with DLZ)
          --with-dlz-mysql=PATH   Build with MySQL DLZ driver [yes|no|path]. (Required
                                  to use MySQL with DLZ)
          --with-dlz-bdb=PATH     Build with Berkeley DB DLZ driver [yes|no|path].
                                  (Required to use Berkeley DB with DLZ)
          --with-dlz-filesystem=ARG
                                  Build with filesystem DLZ driver [yes|no]. (Required
                                  to use file system driver with DLZ)
          --with-dlz-ldap=PATH    Build with LDAP DLZ driver [yes|no|path]. (Required
                                  to use LDAP with DLZ)
          --with-dlz-odbc=PATH    Build with ODBC DLZ driver [yes|no|path]. (Required
                                  to use ODBC with DLZ)
          --with-dlz-stub=ARG     Build with stub DLZ driver [yes|no]. (Required to
                                  use stub driver with DLZ)
          --with-make-clean       run "make clean" at end of configure [yes|no]
        
        Some influential environment variables:
          CC          C compiler command
          CFLAGS      C compiler flags
          LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
                      nonstandard directory <lib dir>
          LIBS        libraries to pass to the linker, e.g. -l<library>
          CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
                      you have headers in a nonstandard directory <include dir>
          CPP         C preprocessor
        
        Use these variables to override the choices made by `configure' or to help
        it to find libraries and programs with nonstandard names/locations.
        
        Professional support for BIND is provided by Internet Systems Consortium,
        Inc.  Information about paid support and training options is available at
        
        Technical support for open source BIND 9 DNS, Kea DHCP and ISC DHCP software
        Help can also often be found on the BIND Users mailing list (https://lists.isc.org/mailman/listinfo/bind-users) or in the #bind channel of the Freenode IRC service. Report bugs to <info@isc.org>. BIND home page: <https://www.isc.org/downloads/BIND/>.
      • オプション
        • –without-openssl
          OpenSSLを使用しない。OpenSSLを使用しないと暗号化をサポートしなくなる。
          デフォルトではOpenSSLを使用するので、事前にインストールしておく必要がある。
    3. コンパイルする
      make 2>&1 | tee make.log
    4. インストールを行う。
      make install 2>&1 | tee make_install.log
  5. リンク作成、環境変数設定などを行う
    1. インストールディレクトリへのシンボリックリンクを作成する。
      これによって、複数のバージョンを同居させ、リンクを切り替えることで、バージョン変更が可能となる。
      各バージョンの実行ファイルはデフォルトでは各バージョンの設定ファイルを読み込むこととなる。
      rm -f /usr/local/bind
      ln -s /usr/local/`pwd | sed "s/.*\///"` /usr/local/bind
    2. 簡単にアクセスできるように環境変数を設定する
      export BIND_HOME=/usr/local/bind
    3. ツール類にパスを通す
      export PATH=$BIND_HOME/bin:$BIND_HOME/sbin:$PATH
    4. 環境変数を再起動後も有効にする
      echo "" >> /etc/bashrc
      echo "# BIND ENVIRONMENT VARIABLE" >> /etc/bashrc
      echo "export BIND_HOME=$BIND_HOME" >> /etc/bashrc
      echo "export PATH=\$BIND_HOME/bin:\$BIND_HOME/sbin:\$PATH" >> /etc/bashrc
    5. 実行できることを確認する
      named -v
      # バージョン情報が出力される
  6. 設定サンプルファイルを使用する場合、コピーする。(基本的には不要)
    cp bin/tests/named.conf $BIND_HOME/etc/
  7. 不要なソースコードを削除する
    cd ../
    rm -rf bind*
  8. systemdの設定する
    1. サービスファイルを作成する
      ※1024番以下のポートを使用する場合はパラメータ”User”を使用し、root以外を指定してはならない。
      cat > /etc/systemd/system/bind.service << EOT
      [Unit]
      Description=BIND DNS name server
      After=local-fs.target network.target network-online.target
      
      [Service]
      Type=forking
      ExecStart=/usr/local/bind/sbin/named -u bind -t /usr/local/bind/ -c etc/named.conf -L log/named.log
      ExecReload=/usr/local/bind/sbin/rndc reload
      ExecStop=/usr/local/bind/sbin/rndc stop
      PrivateTmp=true
      NonBlocking=yes
      
      [Install]
      WantedBy=multi-user.target
      EOT
    2. 必要であれば、ソケットファイルも作成する。
      ソケットファイルはスーパーデーモンを利用する際に使用する。
      DNSを使用する頻度が低いなら設定しておくと良い。
      cat > /etc/systemd/system/bind.socket << EOT
      [Unit]
      Description=BIND DNS name server activation socket
      
      [Socket]
      BINDIPv6Only=ipv6-only
      ListenStream=0.0.0.0:53
      ListenStream=[::]:53
      KeepAlive=true
      
      [Install]
      WantedBy=sockets.target
      EOT
    3. 作成したファイルを反映する
      systemctl daemon-reload
    4. サービスを有効化する
      systemctl enable bind
    5. サービスが有効化されていることを確認する
      systemctl list-unit-files --type service --no-pager | grep bind
  9. インストールしたディレクトリに移動する
    cd $BIND_HOME
  10. 設定確認コマンドを修正する
    設定確認コマンド(sbin/named-checkconf)はchrootを行う場合は都度オプションが必要である。
    また、chrootを行う場合、変更された基底ディレクトリから設定ファイルを参照できるように指定する必要がある。
    これは毎回行うと手間なので、スクリプトを作成して毎回指定できるようにする。
    mv sbin/named-checkconf sbin/named-checkconf.original
    echo "$BIND_HOME/sbin/named-checkconf.original -t $BIND_HOME etc/named.conf \$*" > sbin/named-checkconf
    chmod 555 sbin/named-checkconf
  11. 設定ファイルを作成する
    設定サンプルファイルを利用しなかった場合に実施する。
    1. 管理アクセス用の鍵ファイルを作成する。
      rndc-confgen -a
      鍵ファイルを別途作成せずに、設定ファイル中に含める場合は次を代わりに実行する。
      rndc-confgen > etc/rndc.key
    2. 基本となる設定ファイルを作成する。
      cat >> etc/named.conf << EOT
      logging {
        channel "channel_default" {
          file "log/named.log";
          severity warning;
          print-category yes;
          print-severity yes;
          print-time yes;
        };
        category default { "channel_default"; };
      };
      
      options {
        directory "/";
        version "version";
      };
      
      include "etc/rndc.key";
      
      controls {
        inet 127.0.0.1 port 953 allow { localhost; } keys { "rndc-key"; };
      };
      EOT
    3. ディレクトリ作成
      1. ログ
        ログをsyslogではなくファイルに直接出力する設定を行ったので、出力先のディレクトリを作成する。
        mkdir log
      2. ゾーン
        ゾーンファイルは専用にディレクトリを作成した方が管理しやすい。
        また、スレーブサーバとしてゾーンファイルを受け取った場合は、別に管理した方が扱いやすい。
        mkdir zone-master zone-slave
    4. 設定ファイルに誤りがないか確認する
      問題があれば、”Error”が出力される
      named-checkconf
  12. ファイル所有者を変更する
    chown -R bind:bind /usr/local/bind*
  13. BINDを起動する
    systemctl start bind
  14. 稼働確認
    rndc status
    正常に起動していない場合、ログを確認する。
    journalctl -u bind
    cat $BIND_HOME/log/named.log
    • 出力例
      [root@dns etc]# rndc status
      version: BIND 9.11.3 (Extended Support Version) <id:a375815> (version)
      running on dns.corp: Linux x86_64 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 19:03:37 UTC 2018
      boot time: Wed, 23 May 2018 14:46:52 GMT
      last configured: Wed, 23 May 2018 14:46:52 GMT
      configuration file: /etc/named.conf (/usr/local/bind//etc/named.conf)
      CPUs found: 1
      worker threads: 1
      UDP listeners per interface: 1
      number of zones: 99 (98 automatic)
      debug level: 0
      xfers running: 0
      xfers deferred: 0
      soa queries in progress: 0
      query logging is OFF
      recursive clients: 0/900/1000
      tcp clients: 0/150
      server is up and running
  15. 停止
    systemctl stop bind
  16. ゾーンのテスト
    ゾーンファイルを作成して動作確認する場合、次のサンプルゾーンを追記する。
    1. ゾーン設定の追記
      cat >> $BIND_HOME/etc/named.conf << EOT
      
      zone "example.com" {
        type master;
        file "zone-master/example.com";
        allow-query {any;};
      };
      EOT
    2. ゾーンファイルの作成
      cat > $BIND_HOME/zone-master/example.com << EOT
      @  86400 IN SOA ns example.com. (
           2018052301  ;serial
           5m  ;refresh
           5m  ;retry
           5m  ;expire
           5m  ;minimum ttl each record
            )
      
      ; same as line "ns"
        60 IN NS ns
      
      ; "www" is 10.0.0.2
      www  60 IN A 10.0.0.2
      
      ; "example.com" (=@) is 10.0.0.1
      @  60 IN A 10.0.0.1
      
      ; "ns" is 192.168.0.10
      ns  60 IN A 192.168.0.10
      EOT
      chown bind:bind $BIND_HOME/zone-master/example.com
    3. 解決テスト
      dig @localhost +norecurse example.com
      解決できないことを確認
      ;example.com.                   IN      A
    4. 設定読み込み
      rndc reload
    5. 解決テスト
      dig @localhost +norecurse example.com
      解決できることを確認
      ;; ANSWER SECTION:
      example.com.            60      IN      A       10.0.0.1
      
      ;; AUTHORITY SECTION:
      example.com.            60      IN      NS      ns.example.com.
      
      ;; ADDITIONAL SECTION:
      ns.example.com.         60      IN      A       192.168.0.10
    6. ゾーン転送テスト
      ローカルホストから実施すること。
      dig @localhost axfr example.com

BIND設定


設定変更後、以下のコマンドで設定ファイルの妥当性確認を行うことができる。
named-checkconf
設定の反映は次のコマンドで行う
rndc reload
or
service reload bind

設定サンプル


named.confの設定サンプルはソースコードディレクトリに多数含まれている。

次のコマンドで確認できる。
find ~/bind-*/ -name named.conf

以下のようなサンプルが存在する。

<ソースコード>/bin/tests/named.conf
<ソースコード>/bin/tests/system/acl/ns3/named.conf
<ソースコード>/bin/tests/system/acl/ns4/named.conf
<ソースコード>/bin/tests/system/additional/ns3/named.conf
<ソースコード>/bin/tests/system/addzone/ns1/named.conf
<ソースコード>/bin/tests/system/autosign/ns1/named.conf
<ソースコード>/bin/tests/system/autosign/ns2/named.conf
<ソースコード>/bin/tests/system/autosign/ns3/named.conf
<ソースコード>/bin/tests/system/autosign/ns4/named.conf
<ソースコード>/bin/tests/system/autosign/ns5/named.conf
<ソースコード>/bin/tests/system/builtin/ns1/named.conf
<ソースコード>/bin/tests/system/builtin/ns2/named.conf
<ソースコード>/bin/tests/system/builtin/ns3/named.conf
<ソースコード>/bin/tests/system/cacheclean/ns1/named.conf
<ソースコード>/bin/tests/system/cacheclean/ns2/named.conf
<ソースコード>/bin/tests/system/case/ns1/named.conf
<ソースコード>/bin/tests/system/case/ns2/named.conf
<ソースコード>/bin/tests/system/catz/ns1/named.conf
<ソースコード>/bin/tests/system/catz/ns3/named.conf
<ソースコード>/bin/tests/system/chain/ns1/named.conf
<ソースコード>/bin/tests/system/chain/ns2/named.conf
<ソースコード>/bin/tests/system/chain/ns5/named.conf
<ソースコード>/bin/tests/system/chain/ns7/named.conf
<ソースコード>/bin/tests/system/checknames/ns1/named.conf
<ソースコード>/bin/tests/system/checknames/ns2/named.conf
<ソースコード>/bin/tests/system/checknames/ns3/named.conf
<ソースコード>/bin/tests/system/checknames/ns4/named.conf
<ソースコード>/bin/tests/system/cookie/ns1/named.conf
<ソースコード>/bin/tests/system/cookie/ns2/named.conf
<ソースコード>/bin/tests/system/cookie/ns3/named.conf
<ソースコード>/bin/tests/system/delzone/ns1/named.conf
<ソースコード>/bin/tests/system/delzone/ns2/named.conf
<ソースコード>/bin/tests/system/dialup/ns1/named.conf
<ソースコード>/bin/tests/system/dialup/ns2/named.conf
<ソースコード>/bin/tests/system/dialup/ns3/named.conf
<ソースコード>/bin/tests/system/digdelv/ns1/named.conf
<ソースコード>/bin/tests/system/digdelv/ns2/named.conf
<ソースコード>/bin/tests/system/digdelv/ns3/named.conf
<ソースコード>/bin/tests/system/dlv/ns1/named.conf
<ソースコード>/bin/tests/system/dlv/ns2/named.conf
<ソースコード>/bin/tests/system/dlv/ns3/named.conf
<ソースコード>/bin/tests/system/dlv/ns4/named.conf
<ソースコード>/bin/tests/system/dlv/ns5/named.conf
<ソースコード>/bin/tests/system/dlv/ns6/named.conf
<ソースコード>/bin/tests/system/dlz/ns1/named.conf
<ソースコード>/bin/tests/system/dlzexternal/ns1/named.conf
<ソースコード>/bin/tests/system/dns64/ns1/named.conf
<ソースコード>/bin/tests/system/dns64/ns2/named.conf
<ソースコード>/bin/tests/system/dnssec/ns1/named.conf
<ソースコード>/bin/tests/system/dnssec/ns2/named.conf
<ソースコード>/bin/tests/system/dnssec/ns3/named.conf
<ソースコード>/bin/tests/system/dnssec/ns6/named.conf
<ソースコード>/bin/tests/system/dnssec/ns7/named.conf
<ソースコード>/bin/tests/system/dnstap/ns1/named.conf
<ソースコード>/bin/tests/system/dnstap/ns2/named.conf
<ソースコード>/bin/tests/system/dnstap/ns3/named.conf
<ソースコード>/bin/tests/system/dnstap/ns4/named.conf
<ソースコード>/bin/tests/system/dscp/ns1/named.conf
<ソースコード>/bin/tests/system/dscp/ns2/named.conf
<ソースコード>/bin/tests/system/dscp/ns3/named.conf
<ソースコード>/bin/tests/system/dscp/ns4/named.conf
<ソースコード>/bin/tests/system/dscp/ns5/named.conf
<ソースコード>/bin/tests/system/dscp/ns6/named.conf
<ソースコード>/bin/tests/system/dscp/ns7/named.conf
<ソースコード>/bin/tests/system/dsdigest/ns1/named.conf
<ソースコード>/bin/tests/system/dsdigest/ns2/named.conf
<ソースコード>/bin/tests/system/dsdigest/ns3/named.conf
<ソースコード>/bin/tests/system/dsdigest/ns4/named.conf
<ソースコード>/bin/tests/system/dyndb/ns1/named.conf
<ソースコード>/bin/tests/system/ecdsa/ns1/named.conf
<ソースコード>/bin/tests/system/ecdsa/ns2/named.conf
<ソースコード>/bin/tests/system/eddsa/ns1/named.conf
<ソースコード>/bin/tests/system/eddsa/ns2/named.conf
<ソースコード>/bin/tests/system/ednscompliance/ns1/named.conf
<ソースコード>/bin/tests/system/fetchlimit/ns1/named.conf
<ソースコード>/bin/tests/system/fetchlimit/ns2/named.conf
<ソースコード>/bin/tests/system/formerr/ns1/named.conf
<ソースコード>/bin/tests/system/forward/ns1/named.conf
<ソースコード>/bin/tests/system/forward/ns2/named.conf
<ソースコード>/bin/tests/system/forward/ns3/named.conf
<ソースコード>/bin/tests/system/forward/ns4/named.conf
<ソースコード>/bin/tests/system/forward/ns5/named.conf
<ソースコード>/bin/tests/system/glue/ns1/named.conf
<ソースコード>/bin/tests/system/gost/ns1/named.conf
<ソースコード>/bin/tests/system/gost/ns2/named.conf
<ソースコード>/bin/tests/system/inline/ns1/named.conf
<ソースコード>/bin/tests/system/inline/ns2/named.conf
<ソースコード>/bin/tests/system/inline/ns3/named.conf
<ソースコード>/bin/tests/system/inline/ns4/named.conf
<ソースコード>/bin/tests/system/inline/ns6/named.conf
<ソースコード>/bin/tests/system/inline/ns7/named.conf
<ソースコード>/bin/tests/system/integrity/ns1/named.conf
<ソースコード>/bin/tests/system/ixfr/ns3/named.conf
<ソースコード>/bin/tests/system/ixfr/ns4/named.conf
<ソースコード>/bin/tests/system/legacy/ns2/named.conf
<ソースコード>/bin/tests/system/legacy/ns3/named.conf
<ソースコード>/bin/tests/system/legacy/ns4/named.conf
<ソースコード>/bin/tests/system/legacy/ns5/named.conf
<ソースコード>/bin/tests/system/legacy/ns6/named.conf
<ソースコード>/bin/tests/system/legacy/ns7/named.conf
<ソースコード>/bin/tests/system/limits/ns1/named.conf
<ソースコード>/bin/tests/system/lwresd/ns1/named.conf
<ソースコード>/bin/tests/system/masterfile/ns1/named.conf
<ソースコード>/bin/tests/system/masterfile/ns2/named.conf
<ソースコード>/bin/tests/system/masterformat/ns1/named.conf
<ソースコード>/bin/tests/system/masterformat/ns2/named.conf
<ソースコード>/bin/tests/system/masterformat/ns3/named.conf
<ソースコード>/bin/tests/system/mkeys/ns2/named.conf
<ソースコード>/bin/tests/system/mkeys/ns3/named.conf
<ソースコード>/bin/tests/system/mkeys/ns5/named.conf
<ソースコード>/bin/tests/system/names/ns1/named.conf
<ソースコード>/bin/tests/system/notify/ns1/named.conf
<ソースコード>/bin/tests/system/notify/ns2/named.conf
<ソースコード>/bin/tests/system/notify/ns3/named.conf
<ソースコード>/bin/tests/system/notify/ns4/named.conf
<ソースコード>/bin/tests/system/notify/ns5/named.conf
<ソースコード>/bin/tests/system/nslookup/ns1/named.conf
<ソースコード>/bin/tests/system/nsupdate/ns1/named.conf
<ソースコード>/bin/tests/system/nsupdate/ns2/named.conf
<ソースコード>/bin/tests/system/nsupdate/ns3/named.conf
<ソースコード>/bin/tests/system/nsupdate/ns5/named.conf
<ソースコード>/bin/tests/system/nzd2nzf/ns1/named.conf
<ソースコード>/bin/tests/system/pending/ns1/named.conf
<ソースコード>/bin/tests/system/pending/ns2/named.conf
<ソースコード>/bin/tests/system/pending/ns3/named.conf
<ソースコード>/bin/tests/system/pending/ns4/named.conf
<ソースコード>/bin/tests/system/pipelined/ns1/named.conf
<ソースコード>/bin/tests/system/pipelined/ns2/named.conf
<ソースコード>/bin/tests/system/pipelined/ns3/named.conf
<ソースコード>/bin/tests/system/pipelined/ns4/named.conf
<ソースコード>/bin/tests/system/pkcs11/ns1/named.conf
<ソースコード>/bin/tests/system/pkcs11ssl/ns1/named.conf
<ソースコード>/bin/tests/system/reclimit/ns1/named.conf
<ソースコード>/bin/tests/system/redirect/ns1/named.conf
<ソースコード>/bin/tests/system/redirect/ns2/named.conf
<ソースコード>/bin/tests/system/redirect/ns3/named.conf
<ソースコード>/bin/tests/system/redirect/ns4/named.conf
<ソースコード>/bin/tests/system/resolver/ns1/named.conf
<ソースコード>/bin/tests/system/resolver/ns4/named.conf
<ソースコード>/bin/tests/system/resolver/ns5/named.conf
<ソースコード>/bin/tests/system/resolver/ns6/named.conf
<ソースコード>/bin/tests/system/rndc/ns2/named.conf
<ソースコード>/bin/tests/system/rndc/ns3/named.conf
<ソースコード>/bin/tests/system/rndc/ns5/named.conf
<ソースコード>/bin/tests/system/rpz/ns1/named.conf
<ソースコード>/bin/tests/system/rpz/ns2/named.conf
<ソースコード>/bin/tests/system/rpz/ns3/named.conf
<ソースコード>/bin/tests/system/rpz/ns4/named.conf
<ソースコード>/bin/tests/system/rpz/ns5/named.conf
<ソースコード>/bin/tests/system/rpz/ns6/named.conf
<ソースコード>/bin/tests/system/rpz/ns7/named.conf
<ソースコード>/bin/tests/system/rpzrecurse/ns1/named.conf
<ソースコード>/bin/tests/system/rpzrecurse/ns4/named.conf
<ソースコード>/bin/tests/system/rrl/ns1/named.conf
<ソースコード>/bin/tests/system/rrl/ns2/named.conf
<ソースコード>/bin/tests/system/rrl/ns3/named.conf
<ソースコード>/bin/tests/system/rrl/ns4/named.conf
<ソースコード>/bin/tests/system/rrsetorder/ns1/named.conf
<ソースコード>/bin/tests/system/rrsetorder/ns2/named.conf
<ソースコード>/bin/tests/system/rrsetorder/ns3/named.conf
<ソースコード>/bin/tests/system/rrsetorder/ns4/named.conf
<ソースコード>/bin/tests/system/rsabigexponent/ns1/named.conf
<ソースコード>/bin/tests/system/rsabigexponent/ns2/named.conf
<ソースコード>/bin/tests/system/rsabigexponent/ns3/named.conf
<ソースコード>/bin/tests/system/sfcache/ns1/named.conf
<ソースコード>/bin/tests/system/sfcache/ns2/named.conf
<ソースコード>/bin/tests/system/sfcache/ns5/named.conf
<ソースコード>/bin/tests/system/sortlist/ns1/named.conf
<ソースコード>/bin/tests/system/spf/ns1/named.conf
<ソースコード>/bin/tests/system/staticstub/ns1/named.conf
<ソースコード>/bin/tests/system/staticstub/ns4/named.conf
<ソースコード>/bin/tests/system/statistics/ns1/named.conf
<ソースコード>/bin/tests/system/statistics/ns2/named.conf
<ソースコード>/bin/tests/system/statistics/ns3/named.conf
<ソースコード>/bin/tests/system/statschannel/ns2/named.conf
<ソースコード>/bin/tests/system/stress/ns1/named.conf
<ソースコード>/bin/tests/system/stress/ns2/named.conf
<ソースコード>/bin/tests/system/stress/ns3/named.conf
<ソースコード>/bin/tests/system/stress/ns4/named.conf
<ソースコード>/bin/tests/system/stub/ns1/named.conf
<ソースコード>/bin/tests/system/stub/ns2/named.conf
<ソースコード>/bin/tests/system/stub/ns3/named.conf
<ソースコード>/bin/tests/system/tcp/ns1/named.conf
<ソースコード>/bin/tests/system/tcp/ns2/named.conf
<ソースコード>/bin/tests/system/tcp/ns3/named.conf
<ソースコード>/bin/tests/system/tcp/ns4/named.conf
<ソースコード>/bin/tests/system/tsig/ns1/named.conf
<ソースコード>/bin/tests/system/tsiggss/ns1/named.conf
<ソースコード>/bin/tests/system/unknown/ns1/named.conf
<ソースコード>/bin/tests/system/unknown/ns2/named.conf
<ソースコード>/bin/tests/system/unknown/ns3/named.conf
<ソースコード>/bin/tests/system/upforwd/ns1/named.conf
<ソースコード>/bin/tests/system/upforwd/ns2/named.conf
<ソースコード>/bin/tests/system/upforwd/ns3/named.conf
<ソースコード>/bin/tests/system/v6synth/ns1/named.conf
<ソースコード>/bin/tests/system/v6synth/ns2/named.conf
<ソースコード>/bin/tests/system/v6synth/ns3/named.conf
<ソースコード>/bin/tests/system/views/ns1/named.conf
<ソースコード>/bin/tests/system/views/ns5/named.conf
<ソースコード>/bin/tests/system/wildcard/ns1/named.conf
<ソースコード>/bin/tests/system/wildcard/ns2/named.conf
<ソースコード>/bin/tests/system/wildcard/ns3/named.conf
<ソースコード>/bin/tests/system/wildcard/ns4/named.conf
<ソースコード>/bin/tests/system/wildcard/ns5/named.conf
<ソースコード>/bin/tests/system/xfer/ns1/named.conf
<ソースコード>/bin/tests/system/xfer/ns2/named.conf
<ソースコード>/bin/tests/system/xfer/ns3/named.conf
<ソースコード>/bin/tests/system/xfer/ns6/named.conf
<ソースコード>/bin/tests/system/xfer/ns7/named.conf
<ソースコード>/bin/tests/system/xfer/ns8/named.conf
<ソースコード>/bin/tests/system/xferquota/ns1/named.conf
<ソースコード>/bin/tests/system/xferquota/ns2/named.conf
<ソースコード>/bin/tests/system/zero/ns1/named.conf
<ソースコード>/bin/tests/system/zero/ns2/named.conf
<ソースコード>/bin/tests/system/zero/ns3/named.conf
<ソースコード>/bin/tests/system/zero/ns4/named.conf
<ソースコード>/bin/tests/system/zonechecks/ns1/named.conf
<ソースコード>/bin/tests/system/zonechecks/ns2/named.conf
<ソースコード>/bin/tests/virtual-time/autosign-ksk/ns1/named.conf
<ソースコード>/bin/tests/virtual-time/autosign-zsk/ns1/named.conf
<ソースコード>/bin/tests/virtual-time/slave/ns1/named.conf
<ソースコード>/contrib/dlz/example/named.conf
<ソースコード>/contrib/dlz/modules/bdbhpt/testing/named.conf
<ソースコード>/contrib/dlz/modules/ldap/testing/named.conf
<ソースコード>/contrib/dlz/modules/mysql/testing/named.conf
<ソースコード>/contrib/dlz/modules/mysqldyn/testing/named.conf
<ソースコード>/contrib/dlz/modules/perl/testing/named.conf
<ソースコード>/contrib/dlz/modules/sqlite3/testing/named.conf
<ソースコード>/contrib/dlz/modules/wildcard/testing/named.conf
<ソースコード>/contrib/dnspriv/named.conf


/bin/tests/named.conf


/*
 * Copyright (C) 1999-2001, 2004, 2007, 2011, 2015, 2016  Internet Systems Consortium, Inc. ("ISC")
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

/* $Id: named.conf,v 1.60 2011/03/03 23:47:31 tbox Exp $ */

/*
 * This is a worthless, nonrunnable example of a named.conf file that has
 * every conceivable syntax element in use.  We use it to test the parser.
 * It could also be used as a conceptual template for users of new features.
 */

/*
 * C-style comments are OK
 */

// So are C++-style comments

# So are shell-style comments

// watch out for ";" -- it's important!

options {
        additional-from-auth true;
        additional-from-cache false;

        version "my version string";
        random-device "/dev/random";
        directory "/tmp";

        port 666;

        sig-validity-interval 33;

# Obsolete
        named-xfer "/usr/libexec/named-xfer";   // _PATH_XFER

        dump-file "named_dump.db";      // _PATH_DUMPFILE
        pid-file "/var/run/named.pid";  // _PATH_PIDFILE
        statistics-file "named.stats";  // _PATH_STATS
        memstatistics-file "named.memstats";    // _PATH_MEMSTATS

        max-cache-ttl 999;
        auth-nxdomain yes;              // always set AA on NXDOMAIN.
                                        // don't set this to 'no' unless
                                        // you know what you're doing -- older
                                        // servers won't like it.

# Obsolete
        deallocate-on-exit no;

        dialup yes;

# Obsolete
        fake-iquery no;

        fetch-glue yes;
        has-old-clients yes;
        host-statistics no;

# Obsolete
        multiple-cnames no;             // if yes, then a name my have more
                                        // than one CNAME RR.  This use
                                        // is non-standard and is not
                                        // recommended, but it is available
                                        // because previous releases supported
                                        // it and it was used by large sites
                                        // for load balancing.

        notify yes;                     // send NOTIFY messages.  You can set
                                        // notify on a zone-by-zone
                                        // basis in the "zone" statement
                                        // see (below)
        recursion yes;
        rfc2308-type1   no;

# Obsolete
        use-id-pool yes;

# Obsolete
        treat-cr-as-space yes;

        also-notify { 10.0.2.3; };

        // The "forward" option is only meaningful if you've defined
        // forwarders.  "first" gives the normal BIND
        // forwarding behavior, i.e. ask the forwarders first, and if that
        // doesn't work then do the full lookup.  You can also say
        // "forward only;" which is what used to be specified with
        // "slave" or "options forward-only".  "only" will never attempt
        // a full lookup; only the forwarders will be used.
        forward first;
        forwarders {
                1.2.3.4;
                5.6.7.8;
        };

        check-names master fail;
        check-names slave warn;
        check-names response ignore;

        allow-query { any; };
        allow-transfer { any; };
        allow-recursion { !any; };
        blackhole { 45/24; };
        keep-response-order { 46/24; };

        listen-on {
                10/24;
                10.0.0.3;
        };

        listen-on port 53 { any; };

        listen-on { 5.6.7.8; };

        listen-on port 1234 {
                !1.2.3.4;
                1.2.3/24;
        };

        listen-on-v6 {
                1:1:1:1:1:1:1:1;
        };

        listen-on-v6 port 777 {
                2:2:2:2:2:2:2:2;
        };

        query-source-v6 address 8:7:6:5:4:3:2:1 port *;
        query-source port * address 10.0.0.54  ;

        lame-ttl 444;

        max-transfer-time-in 300;
        max-transfer-time-out 10;
        max-transfer-idle-in 100;
        max-transfer-idle-out 11;

        max-retry-time 1234;
        min-retry-time 1111;
        max-refresh-time 888;
        min-refresh-time 777;

        max-ncache-ttl 333;
        min-roots 15;
        serial-queries 34;

        transfer-format one-answer;

        transfers-in 10;
        transfers-per-ns 2;
        transfers-out 0;

        transfer-source 10.0.0.5;
        transfer-source-v6 4:3:2:1:5:6:7:8;

        request-ixfr yes;
        provide-ixfr yes;

# Now called 'provide-ixfr'
#    maintain-ixfr-base no;   // If yes, keep transaction log file for IXFR

        max-ixfr-log-size 20m;
        coresize 100;
        datasize 101;
        files 230;
        max-cache-size 1m;
        stacksize 231;
        cleaning-interval 1000;
        heartbeat-interval 1001;
        interface-interval 1002;
        statistics-interval 1003;

        topology {
                10/8;

                !1.2.3/24;

                { 1.2/16; 3/8; };


        };

        sortlist { 10/8; 11/8; };

        tkey-domain     "foo.com";
        tkey-dhkey      "xyz" 666 ;

        rrset-order {
                class IN type A name "foo" order random;
                order cyclic;
        };
};

/*
 * Control listeners, for "ndc".  Every nameserver needs at least one.
 */
controls {
        // 'inet' lines without a 'port' defaults to 'port 953'
        // 'keys' must be used and the list must have at least one entry
        inet * port 52 allow { any; } keys { "key2"; };
        unix "/var/run/ndc" perm 0600 owner 0 group 0;  // ignored by named.
        inet 10.0.0.1 allow { any; key foo; } keys { "key4";};
        inet 10.0.0.2 allow { none; } keys { "key-1"; "key-2"; };
        inet 10.0.0.2 allow { none; };
};

zone "master.demo.zone" {
        type master;                    // what used to be called "primary"
        database "somedb -option1 -option2 arg1 arg2 arg3";
        file "master.demo.zone";
        check-names fail;
        allow-update { none; };
        allow-update-forwarding { 10.0.0.5; !any; };
        allow-transfer { any; };
        allow-query { any; };
        sig-validity-interval 990;
        notify explicit;
        also-notify {  1.0.0.1; };      // don't notify any nameservers other
                                        // than those on the NS list for this
                                        // zone
        forward first;
        forwarders { 10.0.0.3; 1:2:3:4:5:6:7:8; };
};

zone "slave.demo.zone" {
        type slave;                     // what used to be called "secondary"
        file "slave.demo.zone";
        ixfr-base  "slave.demo.zone.ixfr";  // File name for IXFR transaction log file
        masters {
                1.2.3.4 port 10 key "foo"; // where to zone transfer from
                5.6.7.8;
                6.7.8.9 key "zippo";
        };
        transfer-source 10.0.0.53;      // fixes multihoming problems
        check-names warn;
        allow-update { none; };
        allow-transfer { any; };
        allow-update-forwarding { any; };
        allow-query { any; };
        max-transfer-time-in 120;       // if not set, global option is used.
        max-transfer-time-out 1;        // if not set, global option is used.
        max-transfer-idle-in 2; // if not set, global option is used.
        max-transfer-idle-out 3;        // if not set, global option is used.
        also-notify { 1.0.0.2; };
        forward only;
        forwarders { 10.45.45.45; 10.0.0.3; 1:2:3:4:5:6:7:8; };
};

key "non-viewkey" { secret "YWFh" ; algorithm "zzz" ; };

view "test-view" in {
        key "viewkey" { algorithm "xxx" ; secret "eXl5" ; };
        also-notify { 10.2.2.3; };
        trusted-keys {
                foo.com. 4 3 2 "abdefghijklmnopqrstuvwxyz";
        };
        sig-validity-interval 45;
        max-cache-size 100000;
        allow-query { 10.0.0.30;};
        additional-from-cache false;
        additional-from-auth no;
        match-clients { 10.0.0.1 ; };
        check-names master warn;
        check-names slave ignore;
        check-names response fail;
        auth-nxdomain false;
        recursion true;
        provide-ixfr false;
        request-ixfr true;
        fetch-glue true;
        notify false;
        rfc2308-type1 false;
        transfer-source 10.0.0.55;
        transfer-source-v6 4:3:8:1:5:6:7:8;
        query-source port * address 10.0.0.54  ;
        query-source-v6 address 6:6:6:6:6:6:6:6 port *;
        max-transfer-time-out 45;
        max-transfer-idle-out 55;
        cleaning-interval 100;
        min-roots 3;
        lame-ttl 477;
        max-ncache-ttl 333;
        max-cache-ttl 777;
        transfer-format many-answers;
        max-retry-time 7;
        min-retry-time 4;
        max-refresh-time 999;
        min-refresh-time 111;

        zone "view-zone.com" {
                type master;
                allow-update-forwarding { 10.0.0.34;};
                file "view-zone-master";
        };

        server 5.6.7.8 {
                keys "viewkey";
        };

        server 10.9.8.7 {
                keys "non-viewkey";
        };
        dialup yes;
};


zone "stub.demo.zone" {
        type stub;                      // stub zones are like slave zones,
                                        // except that only the NS records
                                        // are transferred.
        dialup yes;
        file "stub.demo.zone";
        masters {
                1.2.3.4 ;               // where to zone transfer from
                5.6.7.8 port 999;
        };
        check-names warn;
        allow-update { none; };
        allow-transfer { any; };
        allow-query { any; };

        max-retry-time 10;
        min-retry-time 11;
        max-refresh-time 12;
        min-refresh-time 13;

        max-transfer-time-in 120;       // if not set, global option is used.
        pubkey 257 255 1 "a useless key";
        pubkey 257 255 1 "another useless key";
};

zone "." {
        type hint;                      // used to be specified w/ "cache"
        file "cache.db";
//      pubkey 257 255 1 "AQP2fHpZ4VMpKo/jc9Fod821uyfY5p8j5h/Am0V/KpBTMZjdXmp9QJe6yFRoIIzkaNCgTIftASdpXGgCwFB2j2KXP/rick6gvEer5VcDEkLR5 ==";
Q};
trusted-keys {
        "." 257 255 1 "AQP2fHpZ4VMpKo/jc9Fod821uyfY5p8j5h/Am0V/KpBTMZjdXmp9QJe6yFRoIIzkaNCgTIftASdpXGgCwFB2j2KXP/rick6gvEer5VcDEkLR5Q== ;
“};
acl can_query { !1.2.3/24; any; };      // network 1.2.3.0 mask 255.255.255.0
                                        // is disallowed; rest are OK
acl can_axfr { 1.2.3.4; can_query; };   // host 1.2.3.4 and any host allowed
                                        // by can_query are OK

zone "disabled-zone.com" {
        type master;
        file "bar";

        max-retry-time 100;
        min-retry-time 110;
        max-refresh-time 120;
        min-refresh-time 130;
};

zone "non-default-acl.demo.zone" {
        type master;
        file "foo";
        allow-query { can_query; };
        allow-transfer { can_axfr; };
        allow-update {
                1.2.3.4;
                5.6.7.8;
        };
        pubkey 666 665 664 "key of the beast";
        // Errors trapped by parser:
        //      identity or name not absolute
        //      'wildcard' match type and no wildcard character in name
        //
        // issues:
        //      - certain rdatatype values (such as "key") are config file keywords and
        //        must be quoted or a syntax error will occur.
        //

        update-policy {
                grant root.domain. subdomain host.domain. A MX CNAME;
                grant sub.root.domain. wildcard *.host.domain. A;
                grant root.domain. name host.domain. a ns md mf cname soa mb mg
                        mr "null" wks ptr hinfo minfo mx txt rp afsdb x25
                        isdn rt nsap sig "key" px gpos aaaa loc nxt srv naptr kx
                        cert a6 dname opt unspec uri tkey tsig ;
                grant foo.bar.com. self foo.bar.com. a;
        };
};

key sample_key {                        // for TSIG; supported by parser
        algorithm hmac-md5;             // but not yet implemented in the
        secret "eW91ciBzZWNyZXQgaGVyZQ=="; // rest of the server
};

key key2 {
        algorithm hmac-md5;
        secret "ZXJlaCB0ZXJjZXMgcm91eQ==";
};

acl key_acl { key sample_key; };        // a request signed with sample_key

server 1.2.3.4 {
        request-ixfr no;
        provide-ixfr no;
        bogus no;                       // if yes, we won't query or listen
                                        // to this server
        transfer-format one-answer;     // set transfer format for this
                                        // server (see the description of
                                        // 'transfer-format' above)
                                        // if not specified, the global option
                                        // will be used
        transfers 0;                    // not implemented
        keys { "sample_key" };  // for TSIG; supported by the parser
                                        // but not yet implemented in the
                                        // rest of the server
# Now called 'request-ixfr'
#       support-ixfr yes;      // for IXFR supported by server
                                        // if yes, the listed server talks IXFR
};

logging {
        /*
         * All log output goes to one or more "channels"; you can make as
         * many of them as you want.
         */

        channel syslog_errors {         // this channel will send errors or
                syslog user;            // or worse to syslog (user facility)
                severity error;
        };

        channel stderr_errors {
                stderr;
        };

        /*
         * Channels have a severity level.  Messages at severity levels
         * greater than or equal to the channel's level will be logged on
         * the channel.  In order of decreasing severity, the levels are:
         *
         *      critical                a fatal error
         *      error
         *      warning
         *      notice                  a normal, but significant event
         *      info                    an informational message
         *      debug 1                 the least detailed debugging info
         *      ...
         *      debug 99                the most detailed debugging info
         */

        /*
         * Here are the built-in channels:
         *
         *      channel default_syslog {
         *              syslog daemon;
         *              severity info;
         *      };
         *
         *      channel default_debug {
         *              file "named.run";       // note: stderr is used instead
         *                                      // of "named.run" if the server
         *                                      // is started with the "-f"
         *                                      // option.
         *              severity dynamic;       // this means log debugging
         *                                      // at whatever debugging level
         *                                      // the server is at, and don't
         *                                      // log anything if not
         *                                      // debugging.
         *      };
         *
         *      channel null {                  // this is the bit bucket;
         *              file "/dev/null";       // any logging to this channel
         *                                      // is discarded.
         *      };
         *
         *      channel default_stderr {        // writes to stderr
         *              file "<stderr>";        // this is illustrative only;
         *                                      // there's currently no way
         *                                      // of saying "stderr" in the
         *                                      // configuration language.
         *                                      // i.e. don't try this at home.
         *              severity info;
         *      };
         *
         *      default_stderr only works before the server daemonizes (i.e.
         *      during initial startup) or when it is running in foreground
         *      mode (-f command line option).
         */

        /*
         * There are many categories, so you can send the logs
         * you want to see wherever you want, without seeing logs you
         * don't want.  Right now the categories are
         *
         *      default                 the catch-all.  many things still
         *                              aren't classified into categories, and
         *                              they all end up here.  also, if you
         *                              don't specify any channels for a
         *                              category, the default category is used
         *                              instead.
         *      config                  high-level configuration file
         *                              processing
         *      parser                  low-level configuration file processing
         *      queries                 what used to be called "query logging"
         *      lame-servers            messages like "Lame server on ..."
         *      statistics
         *      panic                   if the server has to shut itself
         *                              down due to an internal problem, it
         *                              logs the problem here (as well as
         *                              in the problem's native category)
         *      update                  dynamic update
         *      ncache                  negative caching
         *      xfer-in                 zone transfers we're receiving
         *      xfer-out                zone transfers we're sending
         *      db                      all database operations
         *      eventlib                debugging info from the event system
         *                              (see below)
         *      packet                  dumps of packets received and sent
         *                              (see below)
         *      notify                  the NOTIFY protocol
         *      cname                   messages like "XX points to a CNAME"
         *      security                approved/unapproved requests
         *      os                      operating system problems
         *      insist                  consistency check failures
         *      maintenance             periodic maintenance
         *      load                    zone loading
         *      response-checks         messages like
         *                              "Malformed response ..."
         *                              "wrong ans. name ..."
         *                              "unrelated additional info ..."
         *                              "invalid RR type ..."
         *                              "bad referral ..."
         */

        category parser {
                syslog_errors;          // you can log to as many channels
                default_syslog;         // as you want
        };

        category lame-servers { null; };        // don't log these at all

        channel moderate_debug {
                file "foo";                     // foo
                severity debug 3;               // level 3 debugging to file
                print-time yes;                 // timestamp log entries
                print-category yes;             // print category name
                print-severity yes;             // print severity level
                /*
                 * Note that debugging must have been turned on either
                 * on the command line or with a signal to get debugging
                 * output (non-debugging output will still be written to
                 * this channel).
                 */
        };

        channel another {
                file "bar" versions 99 size 10M;
                severity info;
        };

        channel third {
                file "bar" size 100000 versions unlimited;
                severity debug; // use default debug level
        };

        /*
         * If you don't want to see "zone XXXX loaded" messages but do
         * want to see any problems, you could do the following.
         */
        channel no_info_messages {
                syslog;
                severity notice;
        };

        category load { no_info_messages; };

        /*
         * You can also define category "default"; it gets used when no
         * "category" statement has been given for a category.
         */
        category default {
                default_syslog;
                moderate_debug;
        };

        /*
         * If you don't define category default yourself, the default
         * default category will be used.  It is
         *
         *      category default { default_syslog; default_debug; };
         */

        /*
         * If you don't define category panic yourself, the default
         * panic category will be used.  It is
         *
         *      category panic { default_syslog; default_stderr; };
         */

        /*
         * Two categories, 'packet' and 'eventlib', are special.  Only one
         * channel may be assigned to each of them, and it must be a
         * file channel.  If you don't define them  yourself, they default to
         *
         *      category eventlib { default_debug; };
         *
         *      category packet { default_debug; };
         */
};

#include "filename";                    // can't do within a statement


named.conf


メインの設定ファイル


vi $BIND_HOME/etc/named.conf

記法


コメント


コメントの書式は以下がサポートされている。

/* comment */

// comment

# comment



標準設定一覧


次のコマンドで確認可能
postconf -d

設定項目


ACLステートメント


acl string { address_match_element; ... };

CONTROLSステートメント


BINDの管理のためのアクセスリソースを設定する。


inet

rndc接続用のTCPソケットを待ち受けるアドレス、ポートなどを設定する。







unix


DLZステートメント




DYNDBステートメント





KEYステートメント





LOGGINGステートメント





LWRESステートメント





MANAGED-KEYSステートメント





MASTERSステートメント






KEYステートメント





LOGGINGステートメント





category

https://ftp.isc.org/isc/bind9/cur/9.9/doc/arm/Bv9ARM.ch06.html#logging_grammar

LWRESステートメント





MANAGED-KEYSステートメント





MASTERSステートメント





OPTIONSステートメント





version

バージョン情報を記載する。
ndcコマンドの問い合わせやchaosクラスのversion.bind名の問い合わせの際に使用される。

allow-query

DNS問い合わせを許可するホストのリスト

allow-transfer

ゾーン転送を要求することを許可するホスト。
未設定の場合、allow-query-cache設定が使用される。
allow-query-cacheが未設定の場合、allow-query設定が使用される。
allow-queryが未設定の場合、サーバのローカルネットワークとローカルホストのみが許可される。

recursion

再帰問い合わせを許可するかどうか。

allow-recursion

再帰問い合わせを許可するホストのリスト。
未設定の場合、allow-query-cache設定が使用される。
allow-query-cacheが未設定の場合、allow-query設定が使用される。
allow-queryが未設定の場合、サーバのローカルネットワークとローカルホストのみが許可される。

SERVERステートメント





STATISTICS-CHANNELSステートメント





TRUSTED-KEYSステートメント





VIEWステートメント






ZONEステートメント






インストールプログラム





通常プログラム




arpaname


translate IP addresses to the corresponding ARPA names

arpaname

bind9-config


isc-config.shと同じである。

delv


DNS lookup and validation utility

delv

dig



dig [@<問い合わせDNSサーバ>] [+<オプション>] <問い合わせ対象> <ドメイン>

バージョンを確認する


dig @localhost CHAOS version.bind TXT
このコマンドでBINDのバージョンが確認可能である。
脆弱性の露呈になり得るのでバージョン情報は隠すように設定するべきである。
設定はnamed.confに下記のように行う。ダブルクォーテーション内の文字が返されるようになる。
options {
  version "version";
};



host



host

isc-config.sh


インストール時のパスやビルド情報を出力する。
ただし、ソースコードからの再インストールに必要な完全な情報は揃わない。

mdig


DNS pipelined lookup utility

mdig

named-rrchecker


syntax checker for individual DNS resource records

named-rrchecker

nslookup



nslookup

nsupdate


Dynamic DNS update utility



管理プログラム


sbin配下のプログラム

ddns-confgen


ddnsのキーを生成する。

ddns-confgen



dnssec-dsfromkey



dnssec-dsfromkey



dnssec-importkey



dnssec-importkey



dnssec-keyfromlabel




dnssec-keyfromlabel


dnssec-keygen



dnssec-keygen



dnssec-revoke



dnssec-revoke



dnssec-settime



dnssec-settime



dnssec-signzone



dnssec-signzone



dnssec-verify



dnssec-verify



genrandom


ランダムなデータが書き込まれたファイルを生成する。

genrandom <サイズ(KB)> <パス>


isc-hmac-fixup


fixes HMAC keys generated by older versions of BIND

isc-hmac-fixup


lwresd


lightweight resolver daemon

lwresd


named


BINDのデーモンプログラム


named-checkconf


設定ファイル($BIND_HOME/etc/named.conf)のチェックを行う。



named-checkzone


ゾーン情報ファイルのチェックを行う。

named-checkzone


named-compilezone


named-checkzoneのエイリアス


named-journalprint


print zone journal in human-readable form

named-journalprint


nsec3hash


generate NSEC3 hash

nsec3hash


rndc


BINDの管理ツール



rndc-confgen




rndc-confgen


tsig-keygen




tsig-keygen



運用


トラブルシューティング


起動しない


起動直後にshutting downする





動作試験



Notice: Trying to get property 'queue' of non-object in /usr/local/wordpress/wp-includes/script-loader.php on line 2876

Warning: Invalid argument supplied for foreach() in /usr/local/wordpress/wp-includes/script-loader.php on line 2876