TSIG署名の検証

ns.example1.jpがns.example2.jp[10.2.0.3]から受信した、example2.jpゾーンに関するNOTIFYとexample1.jpゾーンに関するゾーン転送要求の署名を検証してみます。
まずns.example1.jpの側で、example2.jpゾーンに関するNOTIFYを署名によりアクセス制限するように、nsd.confの

zone:
        name: example2.jp
                :
                :
        allow-notify: 10.2.0.3 NOKEY
                :
                :


zone:
        name: example2.jp
                :
                :
        allow-notify: 10.2.0.3 ns.example2.jp-ns.example1.jp
                :
                :

に変更します。この設定で、example2.jpゾーンのデータを更新してns.example1.jpにNOTIFYを送出してみると、ns.example1.jpのnsdはログには特にメッセージを出力しませんでしたが、ns.example2.jpのログにゾーン転送要求を受けたというメッセージが出力されないことと、digでns.example1.jpにexample2.jpのSOAをqueryすると、古いデータを返したきたことから、ns.example1.jpのnsdは署名のないNOTIFYを破棄したことがわかります。
続いてns.example2.jpのnamed.confに

server 10.2.0.4 {
        keys {
                ns.example2.jp-ns.example1.jp;
        };
};

という設定を追加します。
ここでexample2.jpゾーンのデータを更新してns.example1.jpにNOTIFYを送出してみると、ns.example2.jpのnamedは

Dec 27 17:36:18 ns.example2.jp named[89981]: notify: info: zone example2.jp/IN: sending notifies (serial 2006122705)
Dec 27 17:36:19 ns.example2.jp named[89981]: xfer-out: info: client 10.2.0.4#61202: transfer of 'example2.jp/IN': AXFR-style IXFR started: TSIG ns.example1.jp-ns.example2.jp
Dec 27 17:36:19 ns.example2.jp named[89981]: xfer-out: info: client 10.2.0.4#61202: transfer of 'example2.jp/IN': AXFR-style IXFR ended

というメッセージをログに出力し、またns.example1.jpのnsdも

Dec 27 17:36:51 ns.example1.jp nsd[86932]: Zone example2.jp serial 2006122704 is updated to 2006122705.

というメッセージをログに出力していることから、ns.example2.jpが送出したNOTIFYが署名されており、ns.example1.jpがそれを受理してゾーン転送を要求したと理解できます。
さらにns.example2.jpから不正な署名をしたNOTIFYを送出してみると、署名のないNOTIFYを送出したときと同じ挙動が観察されたことから、やはりNOTIFYを破棄したことがわかります。
次に、再びns.example2.jpのnamed.confから

server 10.2.0.4 {
        :
        :
};

を削除します。それからns.example1.jpのnsd.confの

zone:
        name: example2.jp
                :
                :
        provide-xfr: 10.2.0.3 NOKEY
                :
                :


zone:
        name: example2.jp
                :
                :
        provide-xfr: 10.2.0.3 ns.example2.jp-ns.example1.jp
                :
                :

に変更します。この設定でexample1.jpゾーンのデータを更新し、nsdc rebuldとnsdc reloadを実行してみると、ns.example1.jpのnsdはログには特にメッセージを出力しませんでしたが、ns.example2.jpのnamedは

Dec 27 17:20:20 ns.example2.jp named[89981]: notify: info: client 10.2.0.4#59162: received notify for zone 'example1.jp': TSIG 'ns.example1.jp-ns.example2.jp'
Dec 27 17:20:20 ns.example2.jp named[89981]: general: info: zone example1.jp/IN: Transfer started.
Dec 27 17:20:20 ns.example2.jp named[89981]: xfer-in: info: transfer of 'example1.jp/IN' from 10.2.0.4#53: connected using 10.2.0.3#53343
Dec 27 17:20:20 ns.example2.jp named[89981]: xfer-in: info: transfer of 'example1.jp/IN' from 10.2.0.4#53: resetting
Dec 27 17:20:20 ns.example2.jp named[89981]: xfer-in: info: transfer of 'example1.jp/IN' from 10.2.0.4#53: connected using 10.2.0.3#52305
Dec 27 17:20:20 ns.example2.jp named[89981]: xfer-in: error: transfer of 'example1.jp/IN' from 10.2.0.4#53: failed while receiving responses: REFUSED
Dec 27 17:20:20 ns.example2.jp named[89981]: xfer-in: info: transfer of 'example1.jp/IN' from 10.2.0.4#53: end of transfer

のようなメッセージをログに出力し、ns.example1.jp[10.2.0.4]のnsdがexample1.jpゾーンのゾーン転送要求を拒否したことがわかり、その理由は、ゾーン転送要求が署名されていなかったことだと推測されます。
次に、ns.example2.jpのnamed.confに

server 10.2.0.4 {
        :
        :
};

を復活させてからexample1.jpゾーンのデータを更新し、nsdc rebuldとnsdc reloadを実行してみると、ns.example1.jpのnsdはログには特にメッセージを出力しませんでしたが、ns.example2.jpのnamedは

Dec 27 18:49:11 ns.example1.jp named[90278]: notify: info: client 10.2.0.4#57855: received notify for zone 'example1.jp': TSIG 'ns.example1.jp-ns.example2.jp'
Dec 27 18:49:11 ns.example1.jp named[90278]: general: info: zone example1.jp/IN: Transfer started.
Dec 27 18:49:11 ns.example1.jp named[90278]: xfer-in: info: transfer of 'example1.jp/IN' from 10.2.0.4#53: connected using 10.2.0.3#62796
Dec 27 18:49:11 ns.example1.jp named[90278]: xfer-in: info: transfer of 'example1.jp/IN' from 10.2.0.4#53: resetting
Dec 27 18:49:11 ns.example1.jp named[90278]: xfer-in: info: transfer of 'example1.jp/IN' from 10.2.0.4#53: connected using 10.2.0.3#49616
Dec 27 18:49:11 ns.example1.jp named[90278]: general: info: zone example1.jp/IN: transferred serial 2006112405: TSIG 'ns.example2.jp-ns.example1.jp'
Dec 27 18:49:11 ns.example1.jp named[90278]: xfer-in: info: transfer of 'example1.jp/IN' from 10.2.0.4#53: end of transfer

のようなメッセージをログに出力し、example1.jpゾーンのゾーン転送が成功したことがわかります。
さらにns.example2.jpから不正な署名をしたゾーン転送の要求を送出してみると、署名がないときと同様の挙動が観察されたことから、ns.example1.jpのnsdがゾーン転送要求を拒否したことがわかります。
tsigによる署名|Up
Copyright(c) 2006, Koh-ichi Ito, All right reserved.
Last update: $Date: 2018-10-21 16:09:48 +0900 (Sun, 21 Oct 2018) $