BINDインストール
# yum -y install bind bind-chroot
BIND設定 [root@falcon21 ~]# vi /etc/named.conf
---------------------
[root@falcon21 ~]# vi /etc/named/named.falcon21.space.zone
zone "falcon21.space" {
file "falcon21.space.db";
};
zone "2.168.192.in-addr.arpa" {
file "2.168.192.in-addr.arpa.db";
};
−−−−−−−−−−−−−−−−−−−−−----------------
[root@falcon21 ~]# vi /etc/named/named.falcon21.space.zone.wan
zone "falcon21.space" {
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_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
rm -f $sort_new $sort_old $diff_out
else
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
-------------------
逆引きゾーンデータベース作成
[root@falcon21 ~]# vi /var/named/2.168.192.in-addr.arpa.db
------------------------
外部向け正引きゾーンデータベース作成
[root@falcon21 ~]# vi /var/named/falcon21.space.db.wan
-------------------------------
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]確認