dnsmasqめも
簡易DNS,dhcpサーバとして使えるようだ。
今回はローカルのdnsキャッシュサーバとして試してみる。
インストール
CentOS5.8ならyumで入った。 # yum install dnsmasq
設定
今回はローカルで試すので下記を記載。 # vim /etc/resolv.conf nameserver 127.0.0.1 #先頭に追加
起動
#/etc/init.d/dnsmasq start
動作状況の確認
そのままだとLOGが出ないのでkillコマンドでSIGUSR1シグナルを送る
# pgrep dnsmasq | xargs kill -s 10 # less /var/log/messages Feb 13 15:50:17 xxx dnsmasq[20395]: time 1360738217 Feb 13 15:50:17 xxx dnsmasq[20395]: cache size 150, 0/16 cache insertions re-used unexpired cache entries. Feb 13 15:50:17 xxx dnsmasq[20395]: queries forwarded 10, queries answered locally 20 Feb 13 15:50:17 xxx dnsmasq[20395]: server 8.8.8.8#53: queries sent 1, retried or failed 0 Feb 13 15:50:17 xxx dnsmasq[20395]: server 8.8.4.4#53: queries sent 10, retried or failed 0
適当に同じドメインを何回か正引きしてから試してみるとlocalでの解決が増えていることがわかる。
Feb 13 15:54:14 xxx dnsmasq[20395]: time 1360738454 Feb 13 15:54:14 xxx dnsmasq[20395]: cache size 150, 0/17 cache insertions re-used unexpired cache entries. Feb 13 15:54:14 xxx dnsmasq[20395]: queries forwarded 11, queries answered locally 38 Feb 13 15:54:14 xxx dnsmasq[20395]: server 8.8.8.8#53: queries sent 1, retried or failed 0 Feb 13 15:54:14 xxx dnsmasq[20395]: server 8.8.4.4#53: queries sent 11, retried or failed
比べてみる
各項目ごとに以下のコマンドを叩いて時間を測ってみる
$ time for count in {1..1000}; do dig teketeke55.hatenablog.com ; done
外部DNSのみ(8.8.8.8)
real 0m21.592s
nscd有効(キャッシュにのせたあと)
real 0m9.687s
dnsmasq有効(キャッシュにのせたあと)
real 0m5.852s
上記の中ではdnsmasqが一番はやかった。