bindによるダイナミックDNSサーバーの運用

目次

検証環境

検証作業内容

DNSコンテンツサーバーの基本設定

/etc/rc.conf

以下の設定を追加する。

named_enable="YES"
named_chrootdir="/var/named"
altlog_proglist="named"

※altlog_proglist が既に設定済みの場合、 namedを追加する。

/usr/local/etc/namedb/named.conf

   1 --- /usr/local/etc/namedb/named.conf.sample     2018-09-13 22:12:15.847935000 +0900
   2 +++ /usr/local/etc/namedb/named.conf    2018-09-13 22:46:26.048986000 +0900
   3 @@ -16,15 +16,20 @@
   4         dump-file       "/var/dump/named_dump.db";
   5         statistics-file "/var/stats/named.stats";
   6 
   7 +       recursion       no;
   8 +       allow-query       { any; };
   9 +       allow-recursion   { none; };
  10 +       allow-query-cache { none; };
  11 +
  12  // If named is being used only as a local resolver, this is a safe default.
  13  // For named to be accessible to the network, comment this option, specify
  14  // the proper IP address, or delete this option.
  15 -       listen-on       { 127.0.0.1; };
  16 +       listen-on       { any; };
  17 
  18  // If you have IPv6 enabled on this system, uncomment this option for
  19  // use as a local resolver.  To give access to the network, specify
  20  // an IPv6 address, or the keyword "any".
  21 -//     listen-on-v6    { ::1; };
  22 +       listen-on-v6    { any; };
  23 
  24  // These zones are already covered by the empty zones listed below.
  25  // If you remove the related empty zones below, comment these lines out.

ゾーンの定義

/usr/local/etc/namedb/TSIGキー名.key

下記コマンドを実行してTSIGキーを発行する。

tsig-keygen -a hmac-sha256 TSIGキー名. > /usr/local/etc/namedb/TSIGキー名.key
chown bind:wheel /usr/local/etc/namedb/TSIGキー名.key
chmod 0400       /usr/local/etc/namedb/TSIGキー名.key

/usr/local/etc/namedb/named.conf

include "/usr/local/etc/namedb/TSIGキー名.key";

zone "example.jp" {
    type         master;
    file         "/usr/local/etc/namedb/dynamic/example.jp";
    allow-update { !{ !ダイナミックDNSクライアントIPアドレス; any; }; key TSIGキー名; };
};

/usr/local/etc/namedb/dynamic/example.jp

$TTL    300

@       IN SOA ns.example.jp. domain.example.jp. (
                2018001401 ; serial
                7200       ; refresh (2 hours)
                900        ; retry (15 minutes)
                2419200    ; expire (4 weeks)
                86400      ; minimum (1 day)
                )
        IN NS   ns
ns      IN A    IPv4アドレス
        IN AAAA IPv6アドレス

chown bind:wheel /usr/local/etc/namedb/dynamic/example.jp
chmod 0644       /usr/local/etc/namedb/dynamic/example.jp

参考文献