BINDを内外向けに設定

By siteadministrator, 5 1月, 2020

BIND9をインストールする。

apt install bind9

rndcキーを作成する。

cd /etc/bind
rndc-confgen -a -b 512 > rndc.conf

rndc.keyのコメントでない部分をnamed.confのOPTION部分以前にコピーする。

"rndc-key" {
    algorithm hmac-md5;
    secret "VLSUjkgxxVDb/b4UtWdiZToO+vPUs+lnSw7FJhxg/CXUX8CF/axBVn+pkQWmuL/n+PfpnqMf5ttOS6ObuqJgCQ==";
};
options {
    default-key "rndc-key";
    default-server 127.0.0.1;
    default-port 953;

}

内部向け部分を設定する。

例)

  • ローカルネットドメイン example.com
  • ローカルネットアドレス 192.168.24.0/24
  • 正引きファイル db.example.com
  • 逆引きファイル db.example.com.rev

db.example.comの内容

$TTL 3D
@ IN SOA server1.example.com. root.example.com. (
    2006080101
    10800
    3600
    604800
    86400 )
IN NS server1.example.com.
IN NS セカンダリネームサーバー
IN MX 10 server2.example.com.
sugioserver1 IN A 192.168.24.17
sugioserver2 IN A 192.168.24.33
gateway IN CNAME server1
bridge IN CNAME server1
www IN A 192.168.24.33
mail IN A 192.168.24.33

db.example.com.revの内容bind9 debian chroot

$ttl 3D
@ IN SOA server1.example.com. root.server1.example.com.
(
    2006080101
    10800
    3600
    604800
    86400 )
IN NS server1.example.com.
17 IN PTR server1.example.com.
33 IN PTR server2.example.com.

bindの主設定ファイルnamed.confを編集する。

acl local-net {
    192.168.24.0/24;
    127.0.0.1;
};
acl second-net {
    XXX.XXX.XXX.XXX; セカンダリDNS
};
key "rndc-key" {
    algorithm hmac-md5;
    secret bind9 debian chroot"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
};
controls {
    inet 127.0.0.1 port 953
    allow { 127.0.0.1; } keys { "rndc-key"; };
};
options {
    directory "/var/cache/bind";
    auth-nxdomain yes; # conform to RFC1035
    allow-transfer { none; };
    listen-on {
        192.168.24.0/24;
        127.0.0.1/8;
        any;
    };
};
view "internal" {
    match-clients { local-net; };
    allow-query { local-net; };
    // prime the server with knowledge of the root servers
    zone "." {
        type hint;
        file "/etc/bind/db.root";bind9 debian chroot
    };
    // be authoritative for the localhost forward and reverse zones, and for
    // broadcast zones as per RFC 1912
    zone "localhost" {
        type master;
        file "/etc/bind/db.local";
    };
    zone "127.in-addr.arpa" {
        type master;
        file "/etc/bind/db.127";
    };
    zone "0.in-addr.arpa" {
        type master;
        file "/etc/bind/db.0";
    };
    zone "255.in-addr.arpa" {
        type master;
        file "/etc/bind/db.255";
    };
    zone "example.com" {
        type master;
        file "/etc/bind/db.example.com";
    };
    zone "24.168.192.in-addr.arpa" {
        type master;
        file "/etc/bind/db.example.com.rev";
    };
};

bind9の再起動後、動作確認を行い、外向けの正引き・逆引きファイルを作成し、外部向け部分を追加する。

view "external" {
    match-clients { any; };
    allow-query { any; };
    recursion no;
    zone "example.com" {
        type master;
        file "/etc/bind/db.outer";bind9 debian chroot
        allow-transfer { セカンダリDNSのアドレス; };
        also-notify { セカンダリDNSのアドレス; };
        notify yes;
    };
    zone "グローバルアドレス.in-addr.arpa" {
        type master;
        file "/etc/bind/db.outer.rev";
        allow-transfer { セカンダリDNSのアドレス; };
        also-notify { セカンダリDNSのアドレス; };
        notify yes;
    };
};

再起動する。

/etc/init.d/bind9 restart

タグ

コメント