BINDインストール
# yum -y install bind bind-chroot

BIND設定                                                                                                                                                                     [root@falcon21 ~]# vi /etc/named.conf

        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        allow-query     { localhost; localnets; };
        allow-recursion { localhost; localnets; };
        allow-query-cache       { localhost; localnets; };
        forwarders      { 8.8.8.8; 8.8.4.4; };
        allow-transfer  { none; };
        /*
         - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
         - If you are building a RECURSIVE (caching) DNS server, you need to enable
           recursion.
         - If your recursive DNS server has a public IP address, you MUST enable access
           control to limit queries to your legitimate users. Failing to do so will
           cause your server to become part of large scale DNS amplification
           attacks. Implementing BCP38 within your network would greatly
           reduce such attack surface
        */
        recursion yes;
 
        /*
        dnssec-enable yes;
        dnssec-validation yes;
        dnssec-lookaside auto;
        */
 
        /* Path to ISC DLV key
        bindkeys-file "/etc/named.iscdlv.key";
 
        managed-keys-directory "/var/named/dynamic";
 
        pid-file "/run/named/named.pid";
        session-keyfile "/run/named/session.key";
        */
};
 
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
        category lame-servers { null; };
};
 
view "internal" {
        match-clients { localnets; };
        match-destinations { localnets; };
 
        zone "." IN {
                type hint;
                file "named.ca";
        };
        include "/etc/named.rfc1912.zones";
        include "/etc/named.root.key";
 
        include "/etc/named/named.falcon21.space.zone";
};
 
view "external" {
        match-clients { any; };
        match-destinations { any; };
        include "/etc/named/named.falcon21.space.zone.wan";
};
 
~
 
 

---------------------
[root@falcon21 ~]# vi /etc/named/named.falcon21.space.zone

zone "falcon21.space" {

type master;
file "falcon21.space.db";

};

zone "2.168.192.in-addr.arpa" {

type master;
file "2.168.192.in-addr.arpa.db";

};

−−−−−−−−−−−−−−−−−−−−−----------------
[root@falcon21 ~]# vi /etc/named/named.falcon21.space.zone.wan
zone "falcon21.space" {

type master;
file "falcon21.space.db.wan";
allow-query { any; };

};

-------------------------------

[root@falcon21 ~]#echo OPTIONS="-4" >> /etc/sysconfig/named

ルートゾーン最新化

[root@falcon21 ~]# dig . ns @198.41.0.4 +bufsize=1024 > /var/named/chroot/var/named/named.ca   

ルートゾーン自動更新設定 
ルートゾーン最新化スクリプト作成
[root@falcon21 ~]# vi named.root_update
#!/bin/bash

new=`mktemp`
errors=`mktemp`

dig . ns @198.41.0.4 +bufsize=1024 > $new 2> $errors

if [ $? -eq 0 ]; then

sort_new=`mktemp`
sort_old=`mktemp`
diff_out=`mktemp`
sort $new > $sort_new
sort /var/named/chroot/var/named/named.ca > $sort_old
diff --ignore-matching-lines=^\; $sort_new $sort_old > $diff_out
if [ $? -ne 0 ]; then
(
echo '-------------------- old named.root --------------------'
cat /var/named/chroot/var/named/named.ca
echo
echo '-------------------- new named.root --------------------'
cat $new
echo '---------------------- difference ----------------------'
cat $diff_out
) | mail -s 'named.root updated' root
cp -f $new /var/named/chroot/var/named/named.ca
chown named. /var/named/chroot/var/named/named.ca
chmod 644 /var/named/chroot/var/named/named.ca
which systemctl > /dev/null 2>&1
if [ $? -eq 0 ]; then
systemctl restart named-chroot > /dev/null
else
/etc/rc.d/init.d/named restart > /dev/null
fi
fi
rm -f $sort_new $sort_old $diff_out

else

cat $errors | mail -s 'named.root update check error' root

fi
rm -f $new $errors


ルートゾーン最新化スクリプトへ実行権限付加
[root@falcon21 ~]# chmod 700 named.root_update 

ルートゾーン最新化スクリプトを毎月自動実行されるディレクトリへ移動
[root@falcon21 ~]# mv named.root_update /etc/cron.monthly/ 

正引きゾーンデータベース作成
[root@falcon21 ~]# vi /var/named/falcon21.space.db

$TTL    86400
@       IN      SOA     falcon21.space.  root.falcon21.space.(
                                      2018041702 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
        IN      NS    falcon21.space.
        IN      MX 10 falcon21.space.
@       IN      A     192.168.2.101
*       IN      A     192.168.2.101
 

-------------------
逆引きゾーンデータベース作成
[root@falcon21 ~]# vi /var/named/2.168.192.in-addr.arpa.db

$TTL    86400
@       IN      SOA     falcon21.space.  root.falcon21.space.(
                                      2018041702 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
        IN      NS    falcon21.space.
101     IN      PTR   falcon21.space.

------------------------

外部向け正引きゾーンデータベース作成
[root@falcon21 ~]# vi /var/named/falcon21.space.db.wan

$TTL    86400
@       IN      SOA     ns1.falcon21.space.  root.falcon21.space.(
                                      2018041702 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
          IN NS    ns1.falcon21.space.
          IN MX 10 falcon21.space.
ns1     IN A     203.181.3.94
@       IN A     203.181.3.94
www   IN A     203.181.3.94
mail    IN A     203.181.3.94
falcon21.space. IN TXT "v=spf1 ip4:203.181.3.94 ~all"
~
 

-------------------------------


BIND起動

[root@falcon21 ~]# systemctl start named-chroot

[root@falcon21 ~]# systemctl enable named-chroot

サーバー自身の問合せ先DNSサーバーを自分自身に変更
[root@falcon21 ~]# sed -i 's/DNS1=.*/DNS1=127.0.0.1/g' /etc/sysconfig/network-scripts/ifcfg-enph0s24

[root@falcon21 ~]# systemctl restart network

BIND確認(クライアントが下段ネットワークWindowsの場合)
C:\Users\hayato>nslookup
> falcon21.space
Server: 192.168.0.1
Address: 192.168.0.1#53

Non-authoritative answer:
Name: falcon21.space
Address: 203.181.3.94
Name: falcon21.space
Address: 203.181.3.94
> 192.168.2.101
Server: 192.168.0.1
Address: 192.168.0.1#53

** server can't find 101.2.168.192.in-addr.arpa: NXDOMAIN
> 203.181.3.94
Server: 192.168.0.1
Address: 192.168.0.1#53

Non-authoritative answer:
94.3.181.203.in-addr.arpa name = q003094.ppp.asahi-net.or.jp.

Authoritative answers can be found from:
>
> exit ← nslookup停止

**********************************************
[root@falcon21 ~]# dig falcon21.space

; <<>> DiG 9.9.4-RedHat-9.9.4-51.el7_4.2 <<>> falcon21.space
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58158
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;falcon21.space. IN A

;; ANSWER SECTION:
falcon21.space. 657 IN A 203.181.3.94
falcon21.space. 657 IN A 203.181.3.94

;; Query time: 15 msec
;; SERVER: 192.168.2.1#53(192.168.2.1)
;; WHEN: ŒŽ 4ŒŽ 30 13:57:36 JST 2018
;; MSG SIZE rcvd: 75

[root@falcon21 ~]# dig -x 203.181.3.94

; <<>> DiG 9.9.4-RedHat-9.9.4-51.el7_4.2 <<>> -x 203.181.3.94
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 14176
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;94.3.181.203.in-addr.arpa. IN PTR

;; ANSWER SECTION:
94.3.181.203.in-addr.arpa. 86250 IN PTR q003094.ppp.asahi-net.or.jp.

;; Query time: 18 msec
;; SERVER: 192.168.2.1#53(192.168.2.1)
;; WHEN: ŒŽ 4ŒŽ 30 13:58:01 JST 2018
;; MSG SIZE rcvd: 95

オープンリゾルバ確認

DNSサーバーがオープンリゾルバ(外部の不特定のIPアドレスからの再帰的な問い合わせを許可しているDNS サーバ)となっていないことを確認する。

[root@centos ~]# wget -qO - http://www.openresolver.jp/cli/check.html ← オープンリゾルバ確認
Configured DNS server: [NOT open] xxx.xxx.xxx.xxx(xxx.xxx.xxx.xxx) ← [NOT open]確認
Source IP address: [NOT open] xxx.xxx.xxx.xxx(falcon21.space) ← [NOT open]確認

投票数:25 平均点:10.00

 
Back to Top