PowerDNS: Bind zone file backendを使ってみる

http://doc.powerdns.com/bindbackend.html
設定はここからのコピペ。

yumでPowerDNSをインスコ。bind backendはビルトインらしい。

yum install pdns

named.caをダウンロード。

wget -O /etc/pdns/named.ca ftp://ftp.nic.ad.jp/internet/rs.internic.net/domain/named.cache

設定ファイルがこんな感じ。


[root@ip-XXX-XXX-XXX-XXX pdns]# pwd
/etc/pdns
[root@ip-XXX-XXX-XXX-XXX pdns]# ls
example.com.rev local.rev named.ca pdns.conf
example.com.zone local.zone named.conf

pdns.confに以下を追記。

bind-config=/etc/pdns/named.conf

named.conf。

acl example {
  127.0.0.1;
};

options {
  directory "/etc/pdns";
};

zone "." {
  type hint;
  file "named.ca";
};

zone "localhost" {
  type master;
  file "local.zone";
};

zone "0.0.127.in-addr.arpa" {
  type master;
  file "local.rev";
};

zone "example.com" {
  type master;
  file "example.com.zone";
};

zone "56.168.192.in-addr.arpa" {
  type master;
  file "example.com.rev";
};

local.zone。

$TTL 86400
@               IN      SOA     localhost.      root.localhost. (
  2002122001 ; serial
  28800  ; refresh 8hr
  14400  ; retry 4hr
  604800 ; expire 1w
  86400  ; default_ttl 24hr
)

              IN      NS      localhost.
              IN      A       127.0.0.1

local.rev。

$TTL 86400
@               IN      SOA     localhost.      root.localhost. (
  2002122001 ; serial
  28800  ; refresh 8hr
  14400  ; retry 4hr
  604800 ; expire 1w
  86400  ; default_ttl 24hr
)

              IN      NS      localhost.
1             IN      PTR     localhost.

example.com.zone。

$TTL 86400
@            IN      SOA dns.example.com. root.example.com. (
                     2002122001 ; serial
                     3600       ; refresh 1hr
                     900        ; retry 15min
                     604800     ; expire 1w
                     86400      ; min 24hr
)
             IN      NS     dns.example.jp.
dns          IN      A      192.168.56.1
srv          IN      A      192.168.56.101

example.com.rev。

$TTL 86400
@            IN      SOA    dns.example.com. root.example.com.  (
                     2002122001      ; Serial
                     3600            ; Refresh
                     900             ; Retry
                     604800          ; Expire
                     3600 )          ; Minimum
             IN      NS    dns.example.com.
1            IN      PTR   dns.example.com.
101          IN      PTR   srv.example.com.

PowerDNSを起動。

/etc/init.d/pdns start

IP、ドメイン名を引っぱってきてみる。


[root@ip-XXX-XXX-XXX-XXX pdns]# dig @127.0.0.1 localhost

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5_5.3 <<>> @127.0.0.1 localhost
; (1 server found)
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50096
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;localhost. IN A

;; ANSWER SECTION:
localhost. 86400 IN A 127.0.0.1

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Dec 20 11:03:19 2010
;; MSG SIZE rcvd: 43

[root@ip-XXX-XXX-XXX-XXX pdns]# dig @127.0.0.1 -x 127.0.0.1

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5_5.3 <<>> @127.0.0.1 -x 127.0.0.1
; (1 server found)
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 9615
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;1.0.0.127.in-addr.arpa. IN PTR

;; ANSWER SECTION:
1.0.0.127.in-addr.arpa. 86400 IN PTR localhost.

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Dec 20 11:03:28 2010
;; MSG SIZE rcvd: 63

[root@ip-XXX-XXX-XXX-XXX pdns]# dig @127.0.0.1 srv.example.com

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5_5.3 <<>> @127.0.0.1 srv.example.com
; (1 server found)
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64693
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;srv.example.com. IN A

;; ANSWER SECTION:
srv.example.com. 86400 IN A 192.168.56.101

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Dec 20 11:03:38 2010
;; MSG SIZE rcvd: 49

[root@ip-XXX-XXX-XXX-XXX pdns]# dig @127.0.0.1 -x 192.168.56.101

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5_5.3 <<>> @127.0.0.1 -x 192.168.56.101
; (1 server found)
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18708
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;101.56.168.192.in-addr.arpa. IN PTR

;; ANSWER SECTION:
101.56.168.192.in-addr.arpa. 86400 IN PTR srv.example.com.

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Dec 20 11:03:46 2010
;; MSG SIZE rcvd: 74