LoginSignup
9
5

More than 5 years have passed since last update.

Install ndjbdns on CentOS

Posted at

Goal

  • DNSソフトとしてdjbdnsが評判いいのでCentOSにインストールする
  • 最終的には、DNSネームサーバとDNSキャッシュサーバを使えるようにする
  • djbdnsのインストールを簡潔にしたn-djbdnsというプロジェクトがあるので、それを使ってinstallする

n-djbdnsとdjbdnsの違い

以下のように書いてある. 機能のコアは変わらない.

  • Make djbdns as much concise & independent as possible.
  • Simplify installation & configuration using GNU auto tools.
  • Drop the various *-conf programs.
  • Follow FHS conventions for all kinds of configuration, data and log files.
  • Write good user manuals and documentation.
  • While doing all of this and more, not to loose track of security and apply all the patches available so far.

Download

sudo su -
cd /usr/local/src

## 
## 以下公式サイトからダウンロード先のリンクを取得
## http://pjp.dgplug.org/ndjbdns/index.html
## 
wget "http://pjp.dgplug.org/ndjbdns/ndjbdns-1.06.tar.gz"
tar zxvf ndjbdns-1.06.tar.gz
ls -l ndjbdns-1.06
cd ndjbdns-1.06

Install

# sudo su -
# cd /usr/local/src/ndjbdns-1.06

./configure --prefix=/usr/local
  # /usr/local/以下にインストールする
make
make install

which dnscache
which tinydns
  # dnscache, tinydnsコマンドへのパスが通ること確認

## 起動スクリプト設定
## (パッケージをダウンロードした/usr/local/src/ndjbdns-1.06以下からコピーしていることに注意!!)
cp -i ./etc/init.d/dnscache /etc/init.d/ 
chmod u+x /etc/init.d/dnscache
  # -rwxr--r-- 1 root root 2036 Jan 24 10:45 /etc/init.d/dnscache

cp -i ./etc/init.d/tinydns /etc/init.d/ 
chmod u+x /etc/init.d/tinydns
  # -rwxr--r-- 1 root root 2036 Jan 24 10:45 /etc/init.d/tinydns

## 
## install directoryを/usr/localに指定すると、
## /usr/local/etc/ndjbdns以下に設定ファイルが保存される.
## だが、起動スクリプトはこれを反映できてないので、手で修正する.
## 

vi /etc/init.d/dnscache
  # configのパスを以下に変更
  # config=/usr/local/etc/ndjbdns/dnscache.conf
vi /etc/init.d/tinydns
  # configのパスを以下に変更
  # config=/usr/local/etc/ndjbdns/tinydns.conf

djbdns Setting

djbdnsはBINDと違って、DNSネームサーバ(権威サーバ)とキャッシュサーバ(再帰検索サーバ)が別デーモンとして分離していて、ネームサーバ=tinydns、キャッシュサーバ=dnscacheとなっている.
DNSの仕様では権威サーバへの問い合わせも再帰検索もポート53を使うため、別のデーモンを同じポートで稼働させるためにそれぞれ別のIPアドレスをバインドして起動させる必要がある.

installディレクトリを/usr/local/にした場合、tinydnsとdnscacheの設定ファイルはそれぞれ以下のファイルとなる.

  • /usr/local/etc/ndjbdns/tinydns.conf
  • /usr/local/etc/ndjbdns/dnscache.conf

それぞれ、127.0.0.1、192.168.2.12にセットする場合は、IP=の部分を以下のように変更する.

/usr/local/etc/ndjbdns/tinydns.conf
IP=127.0.0.1
/usr/local/etc/ndjbdns/dnscache.conf
IP=192.168.2.12

起動

service dnscache start
service tinydns start

## 
## dnscacheはtcp,udp:53で起動するが、tinydnsはudp:53のみで起動する.
## 想定のIPアドレスがバインドされていることを確認
## 
lsof -i:53
  # COMMAND    PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
  # tinydns  23402 daemon    4u  IPv4 373980      0t0  UDP localhost:domain
  # dnscache 28041 daemon    3u  IPv4 406795      0t0  UDP 192.168.2.12:domain
  # dnscache 28041 daemon    4u  IPv4 406796      0t0  TCP 192.168.2.12:domain (LISTEN)

netstat -an | grep :53
  # tcp        0      0 192.168.2.12:53             0.0.0.0:*                   LISTEN
  # udp        0      0 192.168.2.12:53             0.0.0.0:*
  # udp        0      0 127.0.0.1:53                0.0.0.0:*

Environment

uname -a
  # Linux *** 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

cat /etc/issue
  # CentOS release 6.5 (Final)
  # Kernel \r on an \m
9
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
5