DebianにPowerDNSを入れる

Bindの代わりに、PowerDNSを入れてみた。
http://www.powerdns.com/content/home-powerdns.html

Debianにある、pdnsを探してみる

# apt-cache search pdns
ldapdns - DNS server that pulls data from an LDAP directory
ldaptor-utils - command-line LDAP utilities
fpdns - remotely determine DNS server version
libnet-dns-fingerprint-perl - library to determine DNS server vendor, product and version
pdns-recursor - PowerDNS recursor
pdns-backend-geo - geo backend for PowerDNS
pdns-backend-ldap - LDAP backend for PowerDNS
pdns-backend-mysql - generic MySQL backend for PowerDNS
pdns-backend-pgsql - generic PostgreSQL backend for PowerDNS
pdns-backend-pipe - pipe/coprocess backend for PowerDNS
pdns-backend-sqlite3 - sqlite backend for PowerDNS
pdns-backend-sqlite - sqlite backend for PowerDNS
pdns-doc - PowerDNS manual
pdns-server - extremely powerful and versatile nameserver
pdnsd - Proxy DNS Server

で、今回はコンテンツサーバ(外向き)なので、「pdns-server」を入れてみます

コンテンツサーバ・・・pdns-server
キャッシュサーバ・・・pdns-recursor

と分離していますので、必要なものをインストールして下さい。

また、WebGUIとしてPowerAdmin、バックエンドとしてMySQLを使ってみます。
https://www.poweradmin.org/trac/

さくっと必要な物をインストールします。
パッケージがあるのですごく有難い。

# apt-get install pdns-server pdns-backend-mysql mysql-server apache2 php5 php5-mysql php5-mcrypt php-pear dnsutils
# pear install mdb2 mdb2_driver_mysql

「dnsutils」は「dig」をインストールしたい場合

さてここからが、本番です。。。

1)MySQLの設定
参考URL
http://www.howtoforge.com/installing-powerdns-with-mysql-backend-and-poweradmin-on-debian-lenny

Mysqlの設定
ユーザ名・・・power_admin
パスワード・・・power_admin_password
データベース名・・・powerdns

ユーザの作成からテーブルの作成まで一気にやってしまいます。

# mysql -u root -p
> CREATE DATABASE powerdns;

Query OK, 0 rows affected (0.00 sec)
> 
> GRANT ALL ON powerdns.* TO 'power_admin'@'localhost' IDENTIFIED BY 'power_admin_password';

Query OK, 0 rows affected (0.00 sec)
> 
> GRANT ALL ON powerdns.* TO 'power_admin'@'localhost.localdomain' IDENTIFIED BY 'power_admin_password';

Query OK, 0 rows affected (0.00 sec)
> 
> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)
> 
> USE powerdns;

Query OK, 0 rows affected (0.00 sec)
> 
> CREATE TABLE domains (
id INT auto_increment,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL,
primary key (id)
);

Query OK, 0 rows affected (0.00 sec)
> 
> CREATE UNIQUE INDEX name_index ON domains(name);

Query OK, 0 rows affected (0.00 sec)
>
> CREATE TABLE records (
id INT auto_increment,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(6) DEFAULT NULL,
content VARCHAR(255) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
primary key(id)
);

Query OK, 0 rows affected (0.00 sec)
> 
> CREATE INDEX rec_name_index ON records(name);

Query OK, 0 rows affected (0.00 sec)
> 
> CREATE INDEX nametype_index ON records(name,type);

Query OK, 0 rows affected (0.00 sec)
> 
> CREATE INDEX domain_id ON records(domain_id);

Query OK, 0 rows affected (0.00 sec)
> 
> CREATE TABLE supermasters (
ip VARCHAR(25) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) DEFAULT NULL
);

Query OK, 0 rows affected (0.00 sec)
> 
> quit

とりあえず、これでテーブル等は作成できました。

2)PowerDNSの設定
バックエンドの設定をします

# vi /etc/powerdns/pdns.conf

# launch=
launch=gmysql

# vi /etc/powerdns/pdns.d/pdns.local

gmysql-host=127.0.0.1
gmysql-user=power_admin
gmysql-password=power_admin_password
gmysql-dbname=powerdns

# /etc/init.d/pdns restart

これで、PowerDNSは動いているはず

3)Apacheの設定
特に、難しいことは無いと思います。
今回はdocument-rootにそのままおいてみます。

# mkdir /var/www
# cd /tmp
# wget https://www.poweradmin.org/download/poweradmin-2.1.5.tgz --no-check-certificate
# tar zxfv poweradmin-2.1.5.tgz
# cd -R poweradmin-2.1.5/* /var/www/
# chown -R www-data:www-data /var/www
# /etc/init.d/apache2 restart

そのままですw

プロセス数や使わないモジュールなどは

# vi /etc/apache2/apache2.conf

<IfModule mpm_prefork_module>
    StartServers          1
    MinSpareServers       1
    MaxSpareServers       4
    MaxClients            8
    MaxRequestsPerChild   0
</IfModule>
#
# vi /etc/apache2/conf.d/security 

ServerTokens Prod
ServerSignature Off

#
# a2dismod auth_basic authn_file authz_default authz_groupfile authz_user autoindex cgi deflate reqtimeout
# /etc/init.d/apache2 restart

こんな感じで、設定したら良いと思います。

あとはブラウザで
http://powerdnsサーバ/index.php
へアクセスすると、インストールが開始されます。

4)ログの設定
通常は、「/var/log/messages」に書かれます。
僕は分けたいので以下のように設定しました。
「rsyslog.conf」への
「local0.* /var/log/pdns.log」の追記
「local0.none /var/log/messages」の追記

# vi /etc/rsyslog.conf

# First some standard log files.  Log by facility.
#
auth,authpriv.*                 /var/log/auth.log
*.*;auth,authpriv.none          -/var/log/syslog

local0.*                        /var/log/pdns.log


*.=info;*.=notice;*.=warn;\
        auth,authpriv.none;\
        cron,daemon.none;\
        mail,news.none;\
        local0.none             -/var/log/messages

PowerDNSの設定を変更

# vi /etc/powerdns/pdns.conf

# logfile       Logfile to use
#
logfile=/var/log/pdns.log

#################################
# logging-facility      Log under a specific facility
#
logging-facility=0

# /etc/init.d/rsyslog restart
# /etc/init.d/pdns restart

これで、/var/log/pdns.logにログが書かれます。

5)日本語化
そのままだと英語だったので日本語化してみます

# vi /etc/locale.gen

# ja_JP.EUC-JP EUC-JP
 ja_JP.UTF-8 UTF-8

#
# locale-gen
Generating locales (this might take a while)...
  en_US.UTF-8... done
  ja_JP.UTF-8... done
Generation complete.
#
# /etc/init.d/apache2 restart

これで日本語になるはずです。

まだ、本環境には使っていませんが、
設定が固まったら、Bindから移行するかも。。。

[tegaki]どうしようかなー[/tegaki]

コメントを残す

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

Enter code * Time limit is exhausted. Please reload CAPTCHA.

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください