LinuxでDNSキャッシュサーバソフトunboundをインストールしました。

DNSキャッシュサーバを急遽立てる必要に迫られたのでCentOS6.10にunboundをインストールしてみました。

インストールは普通に「yum install unbound」で問題ありません。

[root@localhost ~]# yum install unbound
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp-srv2.kddilabs.jp
 * extras: ftp-srv2.kddilabs.jp~以下略

インストールが完了したら設定ファイルを編集します。設定ファイルは「/etc/unbound/unbound.conf」です。

最初にオリジナルファイルをコピーして修正を行いましょう。

[root@localhost ~]#cp /etc/unbound/unbound.conf /etc/unbound/unbound.conf.org

自分が修正した設定ファイルは下記の通りです。

38行目:コメントアウト
interface: 0.0.0.0147行目/148行目 コメントアウト&追加
access-control: 127.0.0.0/8 allow
access-control: 192.168.0.0/16 allow

551行目 追加
forward-zone:
name: “.”
forward-addr: 8.8.8.8
forward-addr: 8.8.4.4

下記の「remote-control:」関連の設定は不要なので、すべてコメントアウト
remote-control:
control-enable: yes
server-key-file: “/etc/unbound/unbound_server.key”
server-cert-file: “/etc/unbound/unbound_server.pem”
control-key-file: “/etc/unbound/unbound_control.key”
control-cert-file: “/etc/unbound/unbound_control.pem

最終的には下記のような形になりました。(有効な設定だけを抜粋)

server:
verbosity: 1
statistics-interval: 0
statistics-cumulative: no
extended-statistics: yes
num-threads: 2
interface: 0.0.0.0
interface-automatic: no
access-control: 127.0.0.0/8 allow
access-control: 192.168.0.0/16 allow
#        access-control: 172.16.0.0/16 allow
#        access-control: 172.17.0.0/16 allow
chroot: “”
username: “unbound”
directory: “/etc/unbound”
log-time-ascii: yes
pidfile: “/var/run/unbound/unbound.pid”
harden-glue: yes
harden-dnssec-stripped: yes
harden-below-nxdomain: yes
harden-referral-path: yes
use-caps-for-id: no
unwanted-reply-threshold: 10000000
prefetch: yes
prefetch-key: yes
rrset-roundrobin: yes
minimal-responses: yes
trusted-keys-file: /etc/unbound/keys.d/*.key
auto-trust-anchor-file: “/var/lib/unbound/root.key”
val-clean-additional: yes
val-permissive-mode: no
val-log-level: 1
include: /etc/unbound/local.d/*.confinclude: /etc/unbound/conf.d/*.conf

forward-zone:
name: “.”
forward-addr: 8.8.8.8
forward-addr: 8.8.4.4

設定が完了したら起動してみます

[root@localhost ~]# /etc/init.d/unbound restart
unbound を停止中:                                          [  OK  ]
unbound を起動中: Nov 08 02:08:25 unbound[9199:0] warning: increased limit(open files) from 1024 to 8266
[  OK  ]

あれ?何かエラーが出ています。「 unbound-checkconf」を実行してもエラーがありませんが・・・・

[root@localhost ~]# unbound-checkconf
unbound-checkconf: no errors in /etc/unbound/unbound.conf

単純に英語の内容を確認すると「オープンできるファイルを増やしてね」だと考え、設定ファイル( /etc/sysconfig/unbound)にリミットを追加しました。(ulimit -n 8290を追加)

[root@localhost ~]# vim /etc/sysconfig/unbound
ulimit -n 8290

設定を追加したので、設定確認と再起動を実施します。

[root@localhost ~]# unbound-checkconf
unbound-checkconf: no errors in /etc/unbound/unbound.conf
[root@localhost ~]# /etc/init.d/unbound restart
unbound を停止中:                                          [  OK  ]
unbound を起動中:                                          [  OK  ]

エラーもなくなり、再起動も正常に完了しました。

bindに比べると簡単ですぐに利用できますね。Aレコード位であれば簡単に設定できるようなので簡易DNSとしても利用できそうです。もう少し研究が必要ですが・・・・

 

 

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です