DNSSEC + NSUPDATE (dynamique update zone)

Tags: #<Tag:0x00007f63fa8f96d8>

Bonjour,

Avant de créer mes certificats SSL/TLS Let’s Encrypt.

J’essaie de mettre à jour dynamiquement une zone signée en DNSSEC pour vérifier que tout fonctionnerais bien et çà ne fonctionne pas.

Bizarre, j’espère y arriver :wink: :smiley:

Sur/depuis un autre serveur (web), j’utilise nsupdate puisque j’ai un serveur DNS « perso » (sécurisé).

CF : dnsapi · acmesh-official/acme.sh Wiki via ACME

Avec cette commande en « Extra debug mode » çà me retourne bien « NOERROR » mais rien n’y fait :

La commande nsupdate est la suivante →

nsupdate -v -y update-dd-zone:44fIf12345zPqrX74Ksw+8CoA==  -D /root/nsupdate-file.nsupdate

Le fichier de commandes nsupdate :

cat /root/nsupdate-file.nsupdate

server ns1.lab3w.fr
zone ipv10.net
update add _acme-challenge.*.ipv10.net 300 IN TXT "ma super clef !!"
send

Déjà il faut envoyer le bon nom du serveur DNS → si j’ai bien compris celui dans le SOA ? Est-e çà ?

Mais sinon en réponse d’une commande dig je ne vois pas la mise à jour dynamique :

13:13:34 root@lv1.w1a:~ # dig TXT _acme-challenge.test.ipv10.net

; <<>> DiG 9.11.5-P4-5.1+deb10u8-Debian <<>> TXT _acme-challenge.test.ipv10.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 59648
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 78aebd22169728e9ec8dcee463512d77eac4e770a6a8ea1b (good)
;; QUESTION SECTION:
;_acme-challenge.test.ipv10.net.        IN      TXT

;; AUTHORITY SECTION:
ipv10.net.              60      IN      SOA     dns.lab3w.fr. hostmaster.lab3w.fr. 2022092310 300 60 420 60

;; Query time: 0 msec
;; SERVER: 2607:5300:60:9389:15:1:a:1000#53(2607:5300:60:9389:15:1:a:1000)
;; WHEN: jeu. oct. 20 13:13:59 CEST 2022
;; MSG SIZE  rcvd: 146

Et ci-dessous le output de nsupdate :

14:45:30 root@lv1.w1a:~ # nsupdate -v -y update-dd-zone:44fIf12345zPqrX74Ksw+8CoA==  -D  -t 10 /root/nsupdate-file.nsupdate
setup_system()
Creating key...
namefromtext
keycreate
reset_system()
user_interaction()
do_next_command()
do_next_command()
do_next_command()
evaluate_update()
update_addordelete()
do_next_command()
start_update()
send_update()
Sending update to 2607:5300:60:9389:58:0:1:1#53
show_message()
Outgoing update query:
;; ->>HEADER<<- opcode: UPDATE, status: NOERROR, id:  60147
;; flags:; ZONE: 1, PREREQ: 0, UPDATE: 1, ADDITIONAL: 1
;; ZONE SECTION:
;ipv10.net.                     IN      SOA

;; UPDATE SECTION:
_acme-challenge.*.ipv10.net. 300 IN     TXT     "ma super clef !!"

;; TSIG PSEUDOSECTION:
update-dd-zone.                0       ANY     TSIG    hmac-md5.sig-alg.reg.int. 1666183552 300 16 UouhWXcZy/HsDL+bKCs6Ow== 60147 NOERROR 0

update_completed()
tsig verification successful
show_message()

Reply from update query:
;; ->>HEADER<<- opcode: UPDATE, status: REFUSED, id:  60147
;; flags: qr ra; ZONE: 1, PREREQ: 0, UPDATE: 0, ADDITIONAL: 1
;; ZONE SECTION:
;ipv10.net.                     IN      SOA

;; TSIG PSEUDOSECTION:
update-dd-zone.                0       ANY     TSIG    hmac-md5.sig-alg.reg.int. 1666183552 300 16 wgDvXBr4wwOsrU0Z3r61cA== 60147 NOERROR 0

done_update()
reset_system()
user_interaction()
cleanup()
detach tsigkey x0x7fb76c18a0b8
Shutting down task manager
shutdown_program()
Shutting down request manager
Destroy DST lib
Destroying request manager
Freeing the dispatchers
Shutting down dispatch manager
Destroying event
Shutting down socket manager
Shutting down timer manager
Destroying hash context
Destroying name state
Removing log context
Destroying memory context

Et sinon s’en l’extra debug → j’ai un retour « REFUSED »

13:18:18 root@lv1.w1a:~ # nsupdate -v -y update-dd-zone:44fIf12345zPqrX74Ksw+8CoA== /root/nsupdate-file.nsupdate
update failed: REFUSED

Donc, j’ai la bonne clef → parce qu’au début, « au premier test » j’avais : « REFUSED(BADKEY) »

J’ai lu ces articles :

Ma Vie On S’en Fout : DNS dynamique sécurisé avec nsupdate et BIND9 | Ta vie on s'en fout! :smiley:


J’ai essayé de freeze la zone et de la recharger - çà ne marche pas non plus.

Salutations,
Romain

En fait, çà fonctionne bien l’update dynamique de ma zone DNS et sur DNSSEC … :smiley:

Je croyais que je pouvais interroger mon RR de cette façon, à priori non.

19:33:25 root@lv1.dns:~ # dig TXT _acme-challenge.test.ipv10.net @dns.google +short

Il faut envoyer comme cela (bon je pensais un truc de wilcard mais rien à voir au sujet).

19:33:38 root@lv1.dns:~ # dig TXT _acme-challenge.*.ipv10.net @dns.google +short
"ma super clef !!"

Donc,

19:38:58 root@lv1.dns:/etc/bind # ls -l masters/ipv10.net.hosts*
-rw-rw-r-- 1 bind bind  6590 nov.  17 18:33 masters/ipv10.net.hosts
-rw-r--r-- 1 bind bind 22434 nov.  17 18:50 masters/ipv10.net.hosts.signed
-rw-r--r-- 1 bind bind  3427 nov.  17 19:36 masters/ipv10.net.hosts.signed.jnl

La 1ère commande (style) :

19:36:03 root@lv1.w1a:~ # nsupdate -k /root/Kupdate-dd-zone.+157+09871.private /root/nsupdate-file.nsupdate

Les logs sur le serveur DNS « master » après /root/nsupdate-file.nsupdate

==> /var/log/named/ddns.log <==
17-Nov-2022 19:29:41.647 update-security: info: client @0x7fde4423fe70 2607:5300:60:9389:15:1:a:10#40419/key update-dd-zone: signer "update-dd-zone" approved
17-Nov-2022 19:29:41.647 update: info: client @0x7fde4423fe70 2607:5300:60:9389:15:1:a:10#40419/key update-dd-zone: updating zone 'ipv10.net/IN': warning: ownername '_acme-challenge.*.ipv10.net' contains a non-terminal wildcard
17-Nov-2022 19:29:41.647 update: info: client @0x7fde4423fe70 2607:5300:60:9389:15:1:a:10#40419/key update-dd-zone: updating zone 'ipv10.net/IN': adding an RR at '_acme-challenge.*.ipv10.net' TXT "ma super clef !!"

La 2ème commande depuis une autre machine :

19:36:03 root@lv1.w1a:~ # nsupdate -k /root/Kupdate-dd-zone.+157+09871.private /root/nsupdate-file-2.nsupdate

Les logs sur le serveur DNS « master » après /root/nsupdate-file-2.nsupdate

==> /var/log/named/ddns.log <==
17-Nov-2022 19:36:40.336 update-security: info: client @0x7fde34010b50 2607:5300:60:9389:15:1:a:10#56969/key update-dd-zone: signer "update-dd-zone" approved
17-Nov-2022 19:36:40.336 update: info: client @0x7fde34010b50 2607:5300:60:9389:15:1:a:10#56969/key update-dd-zone: updating zone 'ipv10.net/IN': deleting rrset at '_acme-challenge.*.ipv10.net' TXT
17-Nov-2022 19:36:40.336 update: info: client @0x7fde34010b50 2607:5300:60:9389:15:1:a:10#56969/key update-dd-zone: updating zone 'ipv10.net/IN': warning: ownername '_acme-challenge.*.ipv10.net' contains a non-terminal wildcard
17-Nov-2022 19:36:40.336 update: info: client @0x7fde34010b50 2607:5300:60:9389:15:1:a:10#56969/key update-dd-zone: updating zone 'ipv10.net/IN': adding an RR at '_acme-challenge.*.ipv10.net' TXT "ma super clef after update !!"

Et le fichier « .jnl » → le journal des mise à jour de la zone DNS :

19:39:09 root@lv1.dns:/etc/bind # named-journalprint masters/ipv10.net.hosts.signed.jnl
del ipv10.net.          3600    IN      SOA     dns.lab3w.fr. hostmaster.lab3w.fr. 2022111703 300 60 420 60
del ipv10.net.          3600    IN      RRSIG   SOA 13 2 3600 20221217165042 20221117165042 3274 ipv10.net. aj63LIR/2H1SvLGche5EYYK/lGCz9CuM+cAQiAGsUQZ/vHsWkcuHJUOE ldmjWZWwu1OlOz53xCZsXKp//1pDWw==
del KF8VD0TDT65OQ88O8K32S381D0S3OH63.ipv10.net. 60 IN RRSIG     NSEC3 13 3 60 20221217165042 20221117165042 3274 ipv10.net. A02Ir6i1VIwFZlIu//Sfsh5ii9TmRFZQ++BUrrxSZuLkLs64FAitJo6a 9Pr9zJABRXM1gzzRddecIzvDQ22+6g==
del QHEIF6C00FUMLKL86LKFIU0FNN1I0VMD.ipv10.net. 60 IN RRSIG     NSEC3 13 3 60 20221217165042 20221117165042 3274 ipv10.net. QcCiwMZ0uV6mObSdegv1QN7VlZSgN6Ozhjj7iDWOxpeJRUSVG8212a+r h9/CiS9mSkuPN93rz0s3ENiRvx1aCA==
del KF8VD0TDT65OQ88O8K32S381D0S3OH63.ipv10.net. 60 IN NSEC3     1 1 10 9AB46F5505A79FC4 LKNBUB7CI8TIPIQNJJJU26DGIP48TUF6 CNAME RRSIG
del QHEIF6C00FUMLKL86LKFIU0FNN1I0VMD.ipv10.net. 60 IN NSEC3     1 1 10 9AB46F5505A79FC4 T34K47ID2JRAJV7T62D8S7GKHMS7GCFK TXT RRSIG
add ipv10.net.          3600    IN      SOA     dns.lab3w.fr. hostmaster.lab3w.fr. 2022111704 300 60 420 60
add _acme-challenge.*.ipv10.net. 300 IN TXT     "ma super clef !!"
add ipv10.net.          3600    IN      RRSIG   SOA 13 2 3600 20221217182941 20221117172941 3274 ipv10.net. Xg1jgoF1H34Kk4C4kCPM6jzH/Z4MSs081fkEi32kdD70+royvxPjDXn/ YYWwK6sAcJ1JmJY1WjWbt9ESIbqVYQ==
add _acme-challenge.*.ipv10.net. 300 IN RRSIG   TXT 13 4 300 20221217182941 20221117172941 3274 ipv10.net. wYs4QCyYeJOm2//0YNOSCUh7joseLBLLZpvPULJ9cd8IJthC0dxj6e4Z tNBtMDQY4vAI/bd6iX72HJ2pZRCPQA==
add KF8VD0TDT65OQ88O8K32S381D0S3OH63.ipv10.net. 60 IN RRSIG     NSEC3 13 3 60 20221217182941 20221117172941 3274 ipv10.net. yhHVL5Fiy6LAvg3feyty9aa34y2+kCazBxDzwMlNSjkYn3NEJxaYg1EK FydMC5OuZlh1wHQePUv9gVVBtWYA+A==
add L0K9UTVKCBBO589B7R6RGNBAH6JFEGS0.ipv10.net. 60 IN RRSIG     NSEC3 13 3 60 20221217182941 20221117172941 3274 ipv10.net. eC61UAtL9SfBeQRwVr0g2O5ZRlvH6Q8w9qrvNd+T1pyCQDuWxP3OXpBa 0aHV4EfW5+O1OpWC8vYPTxOAl4Qe6w==
add QHEIF6C00FUMLKL86LKFIU0FNN1I0VMD.ipv10.net. 60 IN RRSIG     NSEC3 13 3 60 20221217182941 20221117172941 3274 ipv10.net. dzlizeVxdekFfOme/wLGMb9bdN4D7E2Wlmio2k28zhapFTXrbiAWC1ZL O/HaAGHBD+fBzfiSV+Qdzn55PEW94g==
add S5VQ91K9111TFRL07NFTFHBGUJC3649M.ipv10.net. 60 IN RRSIG     NSEC3 13 3 60 20221217182941 20221117172941 3274 ipv10.net. C7s8H2+DXzYehnV+b/xbkl0KzQmipQCl0Vpp6UjgTlaGOi8OFwthTLxF unOdFLKyB639eQfGyzoA5b5iiTywTA==
add KF8VD0TDT65OQ88O8K32S381D0S3OH63.ipv10.net. 60 IN NSEC3     1 1 10 9AB46F5505A79FC4 L0K9UTVKCBBO589B7R6RGNBAH6JFEGS0 CNAME RRSIG
add L0K9UTVKCBBO589B7R6RGNBAH6JFEGS0.ipv10.net. 60 IN NSEC3     1 1 10 9AB46F5505A79FC4 LKNBUB7CI8TIPIQNJJJU26DGIP48TUF6 TXT RRSIG
add QHEIF6C00FUMLKL86LKFIU0FNN1I0VMD.ipv10.net. 60 IN NSEC3     1 1 10 9AB46F5505A79FC4 S5VQ91K9111TFRL07NFTFHBGUJC3649M TXT RRSIG
add S5VQ91K9111TFRL07NFTFHBGUJC3649M.ipv10.net. 60 IN NSEC3     1 1 10 9AB46F5505A79FC4 T34K47ID2JRAJV7T62D8S7GKHMS7GCFK
del ipv10.net.          3600    IN      SOA     dns.lab3w.fr. hostmaster.lab3w.fr. 2022111704 300 60 420 60
del _acme-challenge.*.ipv10.net. 300 IN TXT     "ma super clef !!"
del ipv10.net.          3600    IN      RRSIG   SOA 13 2 3600 20221217182941 20221117172941 3274 ipv10.net. Xg1jgoF1H34Kk4C4kCPM6jzH/Z4MSs081fkEi32kdD70+royvxPjDXn/ YYWwK6sAcJ1JmJY1WjWbt9ESIbqVYQ==
del _acme-challenge.*.ipv10.net. 300 IN RRSIG   TXT 13 4 300 20221217182941 20221117172941 3274 ipv10.net. wYs4QCyYeJOm2//0YNOSCUh7joseLBLLZpvPULJ9cd8IJthC0dxj6e4Z tNBtMDQY4vAI/bd6iX72HJ2pZRCPQA==
add ipv10.net.          3600    IN      SOA     dns.lab3w.fr. hostmaster.lab3w.fr. 2022111705 300 60 420 60
add _acme-challenge.*.ipv10.net. 300 IN TXT     "ma super clef after update !!"
add ipv10.net.          3600    IN      RRSIG   SOA 13 2 3600 20221217183640 20221117173640 3274 ipv10.net. KjVrgxZIT6zTNE8e5pYeajTyYu48k+4Dagy1kMF4NoFhqheKmht0aGXL Cy9gBYXdWEfMLOMc1+/qXFq1P8XSmQ==
add _acme-challenge.*.ipv10.net. 300 IN RRSIG   TXT 13 4 300 20221217183640 20221117173640 3274 ipv10.net. ILfPh7ibgFAjo3S4rl0zzPdj//fzBJuWUQhKHrd13Wo+iXRWxWfUPSc7 aBgL+ZCZOiF9ALHgT7icuraZ+Ph+xw==
19:42:13 root@lv1.dns:/etc/bind #

J’ai ajouté (vais-je dire) dans un des fichiers de named.conf :

# W1A.LAB3W.FR
server 2607:5300:60:9389:15:1:a:10 {
        transfer-format many-answers;
        keys { "update-dd-zone"; };
};

et :

key "update-dd-zone" {
        algorithm hmac-md5;
        secret "44fIf12345zPqrX74Ksw+8CoA==";
};

Et bien évidement dans la zone en question : allow-update { key "update-dd-zone"; };
De cette manière :

zone "ipv10.net" {
    type master;
    file "/etc/bind/masters/ipv10.net.hosts.signed";

    allow-transfer { key "ns-ldap"; };
    allow-update { key "update-dd-zone"; };
#       update-policy {
#               grant "update-dd-zone" subdomain "ipv10.net." ;
#               grant "update-dd-zone" zonesub "any" ;
#       };

//      notify master-only;
    notify yes;
};

Et donc la réponse d’un resolver DNS :

20:23:38 root@lv1.dns:/etc/bind # dig TXT _acme-challenge.*.ipv10.net @dns.google +short
« ma super clef after update !! »

Super fun !


En passant :

Je vous transmet un lien Web pour configurer les fichiers de logs (copier/coller « Sample Logging Configuration » :wink: ) du serveur DNS BIND9 / NAMED !

Et mon « super » tuto Configuration BIND9 Masters et Slaves :wink:


Et ce lien très intéressant : HOWTO - Déploiement DNSSEC sur vos infrastructures DNSSEC - Version 1 - Copyright AFNIC - Septembre 2013 :slight_smile:

Bonne soirée.
Romain


Note de Moi-même :

En fait, c’était dû à que çà taper sur l’adresse IPv4 (sûrement) et sans le « -t 10 » (pour essayer plusiers fois) de nsupdate çà ne fonctionnait pas selon ma configuration.

Pourtant mon /etc/gai.conf est bien configuré pour prendre l’IPv6 des demandes de connexion réseaux en premier.

Enfin bon çà fonctionne parfaitement.

:slight_smile:

Sinon, j’ai une question :

Çà concerne les fichiers journal « .jnl ».

Pourquoi, faut-il que je supprime les fichiers .jnl de mes zones quand je modifie une zone à la main et que je restart le serveur ?

Si je ne supprime pas le fichier journal .jnl → la zone ne se « valide » pas sur les resolvers, le domaine devient « hors service » ?