ネットワーク備忘録

アラフォーエンジニアのネットワーク系の備忘録。twitter:@deigo25374582

bind_zone転送補足

前回の確認が不正確だったので補足

klock-3rd.hatenablog.com

 

不正確なのはNSレコードのところ
前提として・・・

 

 

DNS1→192.168.1.212

DNS2→192.168.1.213

 

とする。

 

このとき・・・

DNS1のゾーン情報

$ORIGIN .
$TTL 600
test.com    IN SOA ns.test.com root.localhost (
            2016071301   ; serial
            100       ; refresh
            14400      ; retry
            3600      ; expire
            60       ; minimum
            )

        NS   ns1.test.com
        NS   ns2.test.com

$ORIGIN test.com.
www1      CNAME  www
www       A    192.168.1.213
ns1       A    192.168.1.212
ns2       A    192.168.1.213

 

 とし、DNS2のゾーンも↑のZONE情報を受け取っている状態

DNS2でのDig結果もSerialが一緒であることを確認

# dig @localhost test.com any

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.47.rc1.el6 <<>> @localhost test.com any
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55503
;; flags: qr aa rd; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 2
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;test.com.           IN   ANY

;; ANSWER SECTION:
test.com.        600   IN   SOA   ns.test.com. root.localhost. 2016071301 100 14400 3600 60
test.com.        600   IN   NS   ns2.test.com.
test.com.        600   IN   NS   ns1.test.com.

;; ADDITIONAL SECTION:
ns1.test.com.      600   IN   A    192.168.1.212
ns2.test.com.      600   IN   A    192.168.1.213

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Jul 13 19:49:10 2016
;; MSG SIZE rcvd: 147

 

 

 

 ここでDNS1のZONEを修正し、reload

# cat test.com.zone
$ORIGIN .
$TTL 600
test.com    IN SOA ns.test.com root.localhost (
            2016071303   ; serial
            100       ; refresh
            14400      ; retry
            3600      ; expire
            60       ; minimum
            )

        NS   ns1.test.com
        NS   ns2.test.com

$ORIGIN test.com.
www1      CNAME  www
www       A    192.168.1.101
ns1       A    192.168.1.212
ns2       A    192.168.1.213

# rndc reload
server reload successful

 

直後にDNS2でdigしてみる。

 

# dig @localhost www.test.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.47.rc1.el6 <<>> @localhost www.test.com
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64115
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;www.test.com.         IN   A

;; ANSWER SECTION:
www.test.com.      600   IN   A    192.168.1.101

;; AUTHORITY SECTION:
test.com.        600   IN   NS   ns2.test.com.
test.com.        600   IN   NS   ns1.test.com.

;; ADDITIONAL SECTION:
ns1.test.com.      600   IN   A    192.168.1.212
ns2.test.com.      600   IN   A    192.168.1.213

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Jul 13 19:52:19 2016
;; MSG SIZE rcvd: 114

 すると、変更したAレコードが即時変更されている。 もちろんSerialも・・・

 

最初はピンとこなかったけど、「rndc reload」すると、bind9以降はnotify通知をNSレコードのホストに対して投げる模様。 すると受け取ったSlave側がZone転送を要求する模様。 そのため、Zone情報にある、refresh値の時間も掛からずSlave側でAレコードの変更が反映される。

 

・・・ただし、「NSレコードのホストに対して、Notify通知」ってところがポイント。

今回はプライベートアドレスだったけど、IPv4なら当然外部に公開するのであればグローバルIPがNSレコードのホストのアドレスになるはず。

 

DNS1→192.168.1.212→グローバルは1.1.1.1

DNS2→192.168.1.213→グローバルは1.1.1.2

 

# cat test.com.zone
$ORIGIN .
$TTL 600
test.com    IN SOA ns.test.com root.localhost (
            2016071303   ; serial
            100       ; refresh
            14400      ; retry
            3600      ; expire
            60       ; minimum
            )

        NS   ns1.test.com
        NS   ns2.test.com

$ORIGIN test.com.
www1      CNAME  www
www       A    192.168.1.101
ns1       A    1.1.1.1
ns2       A    1.1.1.2

# rndc reload
server reload successful

 

 ↑のような記述だと、rndc reloadでは即時反映されず、serial値まで経過

(1.1.1.2を192.168.1.213に変換してくれるのであれば、おそらく即時転送は可能だと思うが、今回の検証ではNATは用意できず・・・) 

 

ただし、named.confのZoneに「also-notify」でSlave側のIPを記載すれば、
Zone情報のNSのアドレスによらず即時のZone転送は可能。

zone "test.com" IN {
type master;
file "test.com.zone";
also-notify { 192.168.1.213; };
}; 

 

おわり