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としても利用できそうです。もう少し研究が必要ですが・・・・

 

 

SPF(Sender Policy Framework)を設定してみた

簡単に導入できるSMTPを利用したインターネット電子メールの送受信において送信者のドメインの偽称を防ぎ、正当性を検証する仕組みであるSPFを導入してみました。

導入は簡単でDNSサーバのTXTレコードで指定します。

最初にモードの説明。モードは2つあってテストモード(ソフトモード)とハードモードが存在します。ハードモードの場合はSPFで指定したIPアドレスを有するサーバからのメール以外は一切拒否するように指示されます。よって、ほとんどの場合はテストモード(ソフトモード)で運用する事になるでしょう。

◎通常の場合(メールサーバからのみ送受信するとき)は下記でOK。自分が管理しているドメインも下記設定にしています。
v=spf1 +mx ~all

◎メール+WEBサーバのようなときに設定するするには、下記のようにIPアドレスを追加します。
v=spf1 +mx +ip4:36.55.230.135 ~all

◎メールサーバは 36.55.230.135あるが、xxx.xxx.xxx.xxで運用中のウェブサーバのフォームからもメール送信が発生する場合。
“v=spf1 ip4:36.55.230.135 ip4:xxx.xxx.xxx.xx ~all”

◎メールを全く使わない場合(WEB専用ドメインの運用の時に指定する)
example.org. IN TXT “v=spf1 -all”

◎シマンテック.cloud メールプロテクトで利用する設定
テストモード(ソフトモード)
v=spf1 include:spf.messagelabs.com ip4:36.55.230.135 ~all
ハードモード
v=spf1 include:spf.messagelabs.com ip4:36.55.230.135 -all

以上