RFC 5155 解読のためのメモ 2016.9.19 (2017.6.13 updated) T.Suzuki run /jail/bin/dnsspa3.rb by root root server: /usr/local/etc/nsd example server: server_nom1:/usr/local/etc/nsd a.example server: server_sld_nom1:/usr/local/etc/nsd cache server: server_unbound1:/usr/local/etc/unbound Appendix A. Example Zone root---example---+---a.example +ns1 | +ns1.a +ns2 | +ns2.a +ai | +w +---c.example +*.w +ns1.c +x.w +ns2.c +y.w +x.y.w +2t7b4g4vsa5smi47k61mv5bv1a22bojr H(example) = 0p9mhaveqvm6t7vbl5lop2u3t2rp3tom H(c.x.w.example) = 0va5bpr2ou0vk0lbqeeljri88laipsfh (query) H(ns1.example) = 2t7b4g4vsa5smi47k61mv5bv1a22bojr H(x.y.w.example) = 2vptu5timamqttgl4luu9kg21e0aor3s H(a.example) = 35mthgpgcu1qg68fab165klnsnk3dpvl H(c.example) = 4g6p9u5gvfshp30pqecj98b3maqbn1ck (NSEC3 生成は実装依存) H(*.x.w.example) = 92pqneegtaue7pjatc3l3qnk738c6v5m (不存在) H(x.w.example) = b4um86eghhds6nea196smvmlo4ors995 H(ai.example) = gjeqe526plbf1g8mklp59enfd789njgi H(y.w.example) = ji6neoaepv8b5o6k4ev33abha8ht9fgc (query) H(w.example) = k8udemvp1j2f7eg6jebps17vp3n8i58h H(2t7b4g4vsa5smi47k61mv5bv1a22bojr.example) = kohar7mbb8dc2ce8a9qvl8hon4k53uhi H(ns2.example) = q04jkcevqvmu85r014c7dkba38o0ji5r H(*.w.example) = r53bq7cc2uvmubfu5ocmm6pers9tk9en H(xx.example) = t644ebqk9bibcna874givr6joj62mlhv Appendix B. Example Responses B.1. Name Error (a.c.x.w.example の不存在証明) a.c.x.w.example の A の問い合わせに否定応答 (RCODE=3, NXDOMAIN) の例 (以下 1,2 は RFC 5155 と説明順を入れ替えた。また ldns-signzone を使用したため RFC 5155 と一部応答が異なっている) 1. 最近接名 (closest closer) にマッチする NSEC3 a.c.x.w.example の 最近接名 (最長一致の実在する名前) は x.w.example である。 H(x.w.example) = b4um86eghhds6nea196smvmlo4ors995 と計算でき、その値の次の値は gjeqe526plbf1g8mklp59enfd789njgi = H(ai.example) である。(これで x.w.exaple の存在がわかる) b4um86eghhds6nea196smvmlo4ors995.example. NSEC3 1 1 12 aabbccdd ( gjeqe526plbf1g8mklp59enfd789njgi MX RRSIG ) 2. 次近接名 (next closer name) をカバーする NSEC3 近接名 x.w.example. が存在し、次近接名は c.x.w.example. である。 H(c.x.w.example) = 0va5bpr2ou0vk0lbqeeljri88laipsfh と計算でき、その値は H(example) = 0p9mhaveqvm6t7vbl5lop2u3t2rp3tom と H(ns1.example.jp) = 2t7b4g4vsa5smi47k61mv5bv1a22bojr の間にカバーされている。(c.x.w.example. の不存在がわかる) 0p9mhaveqvm6t7vbl5lop2u3t2rp3tom.example. NSEC3 1 1 12 aabbccdd ( 2t7b4g4vsa5smi47k61mv5bv1a22bojr MX DNSKEY NS SOA NSEC3PARAM RRSIG ) 3. a.c.x.w.example. の最近接名のワイルドカード (*.x.w.example.) のハッシュ値は H(*.x.w.example) = 92pqneegtaue7pjatc3l3qnk738c6v5m と計算でき、4g6p9u5gvfshp30pqecj98b3maqbn1ck = H(c.example) と b4um86eghhds6nea196smvmlo4ors995 = H(x.w.example) の間にあり、次の NSEC3 でカバーが示される。(*.x.w.example も不存在) 4g6p9u5gvfshp30pqecj98b3maqbn1ck.example. NSEC3 1 1 12 aabbccdd ( b4um86eghhds6nea196smvmlo4ors995 NS ) 以上で証明(?)されていること: 1. x.w.example. は存在する (最近接名:closest encloser) (最近接名の証明は Section 8.3) 2. c.x.w.example. (次近接名:next closer name) は存在しない 3. *.x.w.example. も存在しない ところで、上記は ldns-signzone で署名したゾーンの場合である。dnssec-signzone を用いた場合、RFC 5155 の例と同様になる。H(c.example) = 4g6p9u5gvfshp30pqecj98b3maqbn1ck の NSEC3 が生成されているかどうかの違いが出る。 ;; NSEC3 RR that covers wildcard at the closest encloser (*.x.w.example) ;; H(*.x.w.example) = 92pqneegtaue7pjatc3l3qnk738c6v5m ;; H(a.example) = 35mthgpgcu1qg68fab165klnsnk3dpvl 35mthgpgcu1qg68fab165klnsnk3dpvl.example. NSEC3 1 1 12 aabbccdd ( b4um86eghhds6nea196smvmlo4ors995 NS DS RRSIG ) B.2. No Data Error (解説省略) B.2.1. No Data Error, Empty Non-Terminal empty non-terminal の問い合わせは "no data" (RCODE=0, Authority Section に SOA付) になる。名前は存在する (NXDOMAIN ではない) がその RR は存在しない。 y.w.example. に No Data 応答の例 ji6neoaepv8b5o6k4ev33abha8ht9fgc.example. NSEC3 1 1 12 aabbccdd ( k8udemvp1j2f7eg6jebps17vp3n8i58h ) ji6neoaepv8b5o6k4ev33abha8ht9fgc.example. RRSIG NSEC3 7 2 3600 ( 20150420235959 20051021000000 40430 example. gPkFp1s2QDQ6wQzcg1uSebZ61W33rUBDcTj7 2F3kQ490fEdp7k1BUIfbcZtPbX3YCpE+sIt0 MpzVSKfTwx4uYA== ) y.w.example. のハッシュ値 ji6neoaepv8b5o6k4ev33abha8ht9fgc にマッチする NSEC3 が存在する (本当に?) が、ビットマップフィールドで RR が空とわかる。 B.3. Referral to an Opt-Out Unsigned Zone この委譲が署名されていないことを証明(?)している。 未署名の委譲が存在することの証明ではないことに注意。 mx.c.example. の MX を問い合わせた例 (RCODE=0, Answerなし、Authority Section に NS) dnssec-signzone だと RFC 5155 の以下の例のようになる。 ;; Header: QR DO RCODE=0 ;; ;; Question mc.c.example. IN MX ;; Answer ;; (empty) ;; Authority c.example. NS ns1.c.example. NS ns2.c.example. ;; NSEC3 RR that covers the "next closer" name (c.example) ;; H(c.example) = 4g6p9u5gvfshp30pqecj98b3maqbn1ck ;; H(a.example) = 35mthgpgcu1qg68fab165klnsnk3dpvl 35mthgpgcu1qg68fab165klnsnk3dpvl.example. NSEC3 1 1 12 aabbccdd ( b4um86eghhds6nea196smvmlo4ors995 NS DS RRSIG ) 35mthgpgcu1qg68fab165klnsnk3dpvl.example. RRSIG NSEC3 7 2 3600 ( 20150420235959 20051021000000 40430 example. g6jPUUpduAJKRljUsN8gB4UagAX0NxY9shwQ Aynzo8EUWH+z6hEIBlUTPGj15eZll6VhQqgZ XtAIR3chwgW+SA== ) ;; NSEC3 RR that matches the closest encloser (example) ;; H(example) = 0p9mhaveqvm6t7vbl5lop2u3t2rp3tom 0p9mhaveqvm6t7vbl5lop2u3t2rp3tom.example. NSEC3 1 1 12 aabbccdd ( 2t7b4g4vsa5smi47k61mv5bv1a22bojr MX DNSKEY NS SOA NSEC3PARAM RRSIG ) 0p9mhaveqvm6t7vbl5lop2u3t2rp3tom.example. RRSIG NSEC3 7 2 3600 ( 20150420235959 20051021000000 40430 example. OSgWSm26B+cS+dDL8b5QrWr/dEWhtCsKlwKL IBHYH6blRxK9rC0bMJPwQ4mLIuw85H2EY762 BOCXJZMnpuwhpA== ) mc.c.example. の証明可能な最近接名は example. でありその NSEC3 が応答されている。また、mc.c.example. の次近接名は c.example であり、そのハッシュ値 H(c.example) = 4g6p9u5gvfshp30pqecj98b3maqbn1ck のカバーが 35mthgpgcu1qg68fab165klnsnk3dpvl = H(a.example) と b4um86eghhds6nea196smvmlo4ors995 = H(x.w.example) で示されている。 ところで、ldns-signzone だと c.example. の NSEC3 レコードが生成されるため、以下のようになる。 ;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 41191 ;; flags: qr rd ; QUERY: 1, ANSWER: 0, AUTHORITY: 4, ADDITIONAL: 2 ;; QUESTION SECTION: ;; mc.c.example. IN A ;; ANSWER SECTION: ;; AUTHORITY SECTION: c.example. 3600 IN NS ns1.c.example. c.example. 3600 IN NS ns2.c.example. 4g6p9u5gvfshp30pqecj98b3maqbn1ck.example. 3600 IN NSEC3 1 1 12 aabbccdd b4um86eghhds6nea196smvmlo4ors995 NS 4g6p9u5gvfshp30pqecj98b3maqbn1ck.example. 3600 IN RRSIG NSEC3 7 2 3600 20161010140307 20160912140307 26567 example. UUzOf9BWg5t3xbcqkV5cMt8UupBar8X4x9yNsiqm5YFJkTQ2uMiolIKhLGxczhm72eexNw3wn4SXOU5Cbldsmn0ATCyBS4JNQnUFWYrNtUIolRmEnzIoDVEKrbrHg+Xl/Z3sbo4hlEvKvEmBQwHIkdJPpq2oYweCIxqJ2rcOB3Q= ----- "ENT was here!!!" について example に以下の委任を加えます。 ex.gov.example. 3600 IN NS ns.ex.gov.example. ns.ex.gov.example. 3600 IN A 192.168.11.21 ldns-signzone で署名します。 # ldns-signzone -n -p -t 12 -s aabbccdd -f example.zone.signed example.ent.zone key/Kexample.+007+26567 key/Kexample.+007+24108 gov.example の下の存在しない名前を検索します。 # drill -D hoge.gov.example @192.168.11.1 4g6p9u5gvfshp30pqecj98b3maqbn1ck.example. 3600 IN NSEC3 1 1 12 aabbccdd b4um86eghhds6nea196smvmlo4ors995 NS jthlauk0mdainrqmnviqj5gqtl3ddnt4.example. 3600 IN NSEC3 1 1 12 aabbccdd k8udemvp1j2f7eg6jebps17vp3n8i58h gjeqe526plbf1g8mklp59enfd789njgi.example. 3600 IN NSEC3 1 1 12 aabbccdd ji6neoaepv8b5o6k4ev33abha8ht9fgc A HINFO AAAA RRSIG # ldns-nsec3-hash -a 1 -t 12 -s aabbccdd hoge.gov.example 55ipsf6g5hv6cadallvuaj8ukngtng28. # ldns-nsec3-hash -a 1 -t 12 -s aabbccdd gov.example jthlauk0mdainrqmnviqj5gqtl3ddnt4. gov.example に NS がないことがわかる --- dnssec-signzone で署名します。 dnssec-signzone -A -H 12 -3 aabbccdd -f example.zone.signed -o example -K key -k Kexample.+007+24108 example.ent.zone Kexample.+007+26567 gov.example の下の存在しない名前を検索します。 # drill -D hoge.gov.example @192.168.11.1 35mthgpgcu1qg68fab165klnsnk3dpvl.example. 3600 IN NSEC3 1 1 12 aabbccdd b4um86eghhds6nea196smvmlo4ors995 NS DS RRSIG gjeqe526plbf1g8mklp59enfd789njgi.example. 3600 IN NSEC3 1 1 12 aabbccdd ji6neoaepv8b5o6k4ev33abha8ht9fgc A HINFO AAAA RRSIG gov.example に NS がないことがわからない --- gov.example. に TXT "ENT was here!!!" を加えて署名し直すと、、、 35mthgpgcu1qg68fab165klnsnk3dpvl.example. 3600 IN NSEC3 1 1 12 aabbccdd b4um86eghhds6nea196smvmlo4ors995 NS DS RRSIG jthlauk0mdainrqmnviqj5gqtl3ddnt4.example. 3600 IN NSEC3 1 1 12 aabbccdd k8udemvp1j2f7eg6jebps17vp3n8i58h TXT RRSIG gjeqe526plbf1g8mklp59enfd789njgi.example. 3600 IN NSEC3 1 1 12 aabbccdd ji6neoaepv8b5o6k4ev33abha8ht9fgc A HINFO AAAA RRSIG