tech:notes_dns_bind9
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| tech:notes_dns_bind9 [2025/06/02 15:17] – Jean-Baptiste | tech:notes_dns_bind9 [2026/06/11 10:32] (Version actuelle) – Jean-Baptiste | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Notes DNS Bind9 | ||
| + | |||
| + | Voir: | ||
| + | * CIS ISC BIND DNS Server Benchmark | ||
| + | |||
| + | Alternative à Bind : | ||
| + | * [unbound](https:// | ||
| + | * PowerDNS | ||
| + | * [Knot DNS](https:// | ||
| + | * [CoreDNS](https:// | ||
| + | |||
| + | |||
| + | ## Import / Export | ||
| + | |||
| + | Si le transfert de zone est activé | ||
| + | |||
| + | Dig gère directement | ||
| + | ~~~bash | ||
| + | dig -t AXFR @127.0.0.1 acme.fr | ||
| + | ~~~ | ||
| + | |||
| + | Si le transfert de zone n'est pas activé on peut toujours essayer | ||
| + | ~~~bash | ||
| + | dig @127.0.0.1 +nocmd +multiline +noall +answer SOA acme.fr | ||
| + | ~~~ | ||
| + | |||
| + | Possibilité de travailler un peu ça (script oneshot un peu pas beau, désolé) | ||
| + | |||
| + | `dig2bind.sh` | ||
| + | ~~~bash | ||
| + | #! /bin/bash | ||
| + | |||
| + | TTL=$(dig acme.fr -t AXFR @127.0.0.1 | egrep -v ' | ||
| + | |||
| + | |||
| + | echo -e " | ||
| + | |||
| + | dig @127.0.0.1 +nocmd +multiline +noall +answer SOA acme.fr | sed -e ' | ||
| + | |||
| + | dig acme.fr -t AXFR @127.0.0.1 | egrep -v ' | ||
| + | |||
| + | |||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | bash dig2bind.sh | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Slave | ||
| + | |||
| + | On slave | ||
| + | |||
| + | Port 53 must be open on Slave (if Notify) | ||
| + | |||
| + | `/ | ||
| + | ~~~c | ||
| + | zone " | ||
| + | type slave; | ||
| + | masters { 192.168.15.211; | ||
| + | allow-notify { 10.8.15.215; | ||
| + | file "/ | ||
| + | allow-transfer { none; } ; | ||
| + | }; | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | On Master | ||
| + | |||
| + | `/ | ||
| + | ~~~c | ||
| + | zone " | ||
| + | type master; | ||
| + | file "/ | ||
| + | allow-transfer { localhost; 192.168.16.45; | ||
| + | notify yes; | ||
| + | }; | ||
| + | ~~~ | ||
| + | |||
| + | `/ | ||
| + | ~~~ | ||
| + | @ | ||
| + | ns1 | ||
| + | ~~~ | ||
| + | |||
| + | Change serial in db.local and reload | ||
| + | |||
| + | |||
| + | ## Forwarder | ||
| + | |||
| + | Il peut-être nécessaire de modifier **allow-query** | ||
| + | |||
| + | `/ | ||
| + | ~~~c | ||
| + | forwarders { | ||
| + | 80.67.169.12; | ||
| + | 80.67.169.40; | ||
| + | }; | ||
| + | allow-query { any; }; | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Récursion | ||
| + | |||
| + | Voir http:// | ||
| + | |||
| + | `/ | ||
| + | ~~~c | ||
| + | options { | ||
| + | |||
| + | /* | ||
| + | - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion. | ||
| + | - If you are building a RECURSIVE (caching) DNS server, you need to enable | ||
| + | | ||
| + | - If your recursive DNS server has a public IP address, you MUST enable access | ||
| + | | ||
| + | cause your server to become part of large scale DNS amplification | ||
| + | | ||
| + | | ||
| + | */ | ||
| + | recursion no; | ||
| + | | ||
| + | /* | ||
| + | ... | ||
| + | */ | ||
| + | | ||
| + | }; | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Désactiver IPV6 | ||
| + | |||
| + | Si l'on n' | ||
| + | |||
| + | ~~~ | ||
| + | OPTIONS=" | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | Voir aussi les options : | ||
| + | * `listen-on` for IPv4 addresses | ||
| + | * `listen-on-v6` for IPv6 addresses | ||
| + | * `query-source` for IPv4 addresses | ||
| + | * `query-source-v6` for IPv6 addresse | ||
| + | |||
| + | Exemple : | ||
| + | ~~~ | ||
| + | options { | ||
| + | // Listen on all IPv4 addresses (default) | ||
| + | listen-on { any; }; | ||
| + | | ||
| + | // No listen on IPv6 | ||
| + | listen-on-v6 { none; }; | ||
| + | }; | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | Il faudra également ajouter une option à / | ||
| + | |||
| + | `/ | ||
| + | ~~~c | ||
| + | options { | ||
| + | // | ||
| + | // Voir AAAA vs A6 | ||
| + | }; | ||
| + | ~~~ | ||
| + | |||
| + | Remplacé par | ||
| + | ~~~c | ||
| + | plugin query " | ||
| + | filter-aaaa-on-v4 yes; | ||
| + | filter-aaaa-on-v6 yes; | ||
| + | filter-aaaa { 192.0.2.1; 2001: | ||
| + | }; | ||
| + | |||
| + | ~~~ | ||
| + | |||
| + | |||
| + | Voir aussi | ||
| + | |||
| + | Prevent your server from using the learned IPv6 addresses itself during recursion | ||
| + | ~~~c | ||
| + | server ::/0 { bogus yes; }; | ||
| + | ~~~ | ||
| + | source : https:// | ||
| + | |||
| + | ------------------------- | ||
| + | |||
| + | # Install DNS Server Bind9 | ||
| + | |||
| + | ## Notes | ||
| + | |||
| + | DNS use port TCP:53 and UDP:53 | ||
| + | |||
| + | |||
| + | ## Install | ||
| + | |||
| + | ~~~bash | ||
| + | apt-get install bind9 bind9utils dnsutils | ||
| + | ~~~ | ||
| + | |||
| + | `/ | ||
| + | ~~~c | ||
| + | zone " | ||
| + | type master; | ||
| + | file "/ | ||
| + | allow-transfer { 10.8.16.47; }; | ||
| + | notify yes; | ||
| + | }; | ||
| + | ~~~ | ||
| + | |||
| + | `/ | ||
| + | ~~~c | ||
| + | $TTL 604800 | ||
| + | @ IN SOA dns.local. root.dns.local. ( | ||
| + | 2015121606 ; serial | ||
| + | 86400 ; refresh (1 day) | ||
| + | 3600 ; retry (1 hour) | ||
| + | 3600000 | ||
| + | 86400 ; minimum (1 day) | ||
| + | ) | ||
| + | |||
| + | @ | ||
| + | @ | ||
| + | @ | ||
| + | dns | ||
| + | ns1 | ||
| + | |||
| + | bastion | ||
| + | proxy | ||
| + | ldap IN A | ||
| + | |||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ### If server must forward | ||
| + | |||
| + | `/ | ||
| + | ~~~c | ||
| + | forwarders { | ||
| + | 10.8.15.1; | ||
| + | }; | ||
| + | allow-query { any; }; | ||
| + | ~~~ | ||
| + | |||
| + | `/ | ||
| + | ~~~ | ||
| + | *.key | ||
| + | *.keys | ||
| + | db.0 | ||
| + | db.127 | ||
| + | db.255 | ||
| + | db.empty | ||
| + | db.local | ||
| + | db.root | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Reload | ||
| + | |||
| + | ~~~bash | ||
| + | rndc reload | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Check | ||
| + | |||
| + | ~~~bash | ||
| + | named-checkconf | ||
| + | named-checkzone local / | ||
| + | |||
| + | #service bind9 reload | ||
| + | rndc reload local | ||
| + | |||
| + | service bind9 status | ||
| + | |||
| + | dig +short @127.0.0.1 bastion.local | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Configure GNU/Linux client | ||
| + | |||
| + | Infra VM | ||
| + | |||
| + | `/ | ||
| + | ~~~ini | ||
| + | #domain local | ||
| + | search local | ||
| + | #options rotate timeout:1 retries:1 | ||
| + | #options edns0 | ||
| + | nameserver 10.8.15.215 | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | VPN clients | ||
| + | |||
| + | `/ | ||
| + | ~~~ini | ||
| + | #domain local | ||
| + | search local | ||
| + | #options rotate timeout:1 retries:1 | ||
| + | nameserver 10.9.0.1 | ||
| + | ~~~ | ||
| + | |||
| + | Prevent DHCP to change / | ||
| + | ~~~bash | ||
| + | chattr +i / | ||
| + | |||
| + | lsattr / | ||
| + | ~~~ | ||
| + | |||
| + | FIXME : A tester avec SystemD (/ | ||
| + | |||
| + | On openvpn-it1 (DNS Slave) | ||
| + | |||
| + | `/ | ||
| + | ~~~c | ||
| + | zone " | ||
| + | type slave; | ||
| + | masters { 10.8.15.215; | ||
| + | allow-notify { 10.8.15.215; | ||
| + | file "/ | ||
| + | allow-transfer { 10.9.0.21; } ; | ||
| + | }; | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Autres | ||
| + | |||
| + | ~~~bash | ||
| + | for fqdn in $(rgrep 192.168.10.22 / | ||
| + | ~~~ | ||
| + | |||
| + | Get TTL | ||
| + | ~~~bash | ||
| + | dig +ttlunits +noall +answer @127.0.0.1 example.org | ||
| + | ~~~ | ||
| + | |||
