tech:notes_client_dns
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_client_dns [2025/04/26 11:09] – Jean-Baptiste | tech:notes_client_dns [2026/06/11 10:16] (Version actuelle) – Jean-Baptiste | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Notes client DNS | ||
| + | |||
| + | Voir aussi les clients DNS : | ||
| + | * [Unbound](https:// | ||
| + | |||
| + | Voir aussi : | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | ### / | ||
| + | |||
| + | Voir aussi: | ||
| + | * / | ||
| + | |||
| + | #### Hard limits for the / | ||
| + | |||
| + | NOTE : Le comportement est différent avec **musl libc** (alternative à glibc) | ||
| + | |||
| + | You need to be aware of the hard limits for name servers, domain name, and search domains when you create or edit the `/ | ||
| + | |||
| + | The hard limits for the `/ | ||
| + | * | ||
| + | * | ||
| + | * | ||
| + | * | ||
| + | * In glibc 2.25 and earlier, the search list is limited to six domains with a total of 256 characters. | ||
| + | * Total number of characters for all search domains is 256. (avant glibc 2.26) | ||
| + | * Note: You should use only tab or space to separate host names in the search domain list. | ||
| + | |||
| + | |||
| + | Si plus de 3 serveurs dans / | ||
| + | |||
| + | |||
| + | Note: There is no limit on file size. | ||
| + | |||
| + | |||
| + | Le mot-clé **search** du fichier `resolv.conf` du système | ||
| + | pour chaque | ||
| + | liste de domaines de recherche séparés par des espaces. \\ | ||
| + | |||
| + | Le mot-clé **options** du fichier `resolv.conf` du système peut être surchargé | ||
| + | pour chaque processus en remplissant la variable d' | ||
| + | d' | ||
| + | |||
| + | |||
| + | |||
| + | ### Redirection de port | ||
| + | |||
| + | ~~~bash | ||
| + | sudo socat -v -v udp4-listen: | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Test connexions | ||
| + | |||
| + | ~~~bash | ||
| + | # UDP | ||
| + | #host -U -W 1 127.0.0.1 8.8.8.8 | ||
| + | host -W 1 127.0.0.1 8.8.8.8 | ||
| + | |||
| + | # TCP | ||
| + | host -T -W 1 127.0.0.1 8.8.8.8 | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | echo " | ||
| + | ~~~ | ||
| + | |||
| + | ~~~yaml | ||
| + | - name: Check DNS connectivity - UDP | ||
| + | command: "host -W 1 127.0.0.1 {{ item | quote }}" | ||
| + | check_mode: false | ||
| + | changed_when: | ||
| + | register: cmd_host_udp | ||
| + | failed_when: | ||
| + | with_items: "{{ resolv_new_nameservers }}" | ||
| + | |||
| + | - name: Check DNS connectivity - TCP | ||
| + | command: "host -T -W 1 127.0.0.1 {{ item | quote }}" | ||
| + | check_mode: false | ||
| + | changed_when: | ||
| + | register: cmd_host_tcp | ||
| + | failed_when: | ||
| + | with_items: "{{ resolv_new_nameservers }}" | ||
| + | |||
| + | ~~~ | ||
| + | |||
| + | |||
| + | Ou encore : | ||
| + | ~~~bash | ||
| + | curl --dns-servers 192.168.0.1, | ||
| + | curl --dns-servers 10.0.0.1:53 https:// | ||
| + | |||
| + | systemd-resolve HOSTNAME SERVERNAME | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Conf Docker | ||
| + | |||
| + | ### Docker-compose | ||
| + | |||
| + | ~~~yaml | ||
| + | my-app: | ||
| + | | ||
| + | dns: | ||
| + | - 10.20.20.1 | ||
| + | - 10.21.21.2 | ||
| + | | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ~~~yaml | ||
| + | spec: | ||
| + | containers: | ||
| + | - name: test | ||
| + | image: nginx | ||
| + | dnsConfig: | ||
| + | options: | ||
| + | - name: timeout | ||
| + | value: " | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ~~~yaml | ||
| + | extra_hosts: | ||
| + | - " | ||
| + | - " | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ## Cache DNS coté client | ||
| + | |||
| + | Voir aussi : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * Rescached | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | `/ | ||
| + | ~~~ini | ||
| + | DNS=1.1.1.1 1.0.0.1 | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | sudo mv / | ||
| + | |||
| + | sudo ln -s / | ||
| + | ~~~ | ||
| + | |||
| + | `/ | ||
| + | ~~~bash | ||
| + | nameserver 127.0.0.53 | ||
| + | options edns0 | ||
| + | ~~~ | ||
| + | |||
| + | **Voir aussi `/ | ||
| + | |||
| + | ~~~bash | ||
| + | sudo pkill -USR1 systemd-resolve | ||
| + | sudo systemd-resolve --flush-caches | ||
| + | sudo resolvectl flush-caches | ||
| + | |||
| + | sudo journalctl -u systemd-resolved > ~/ | ||
| + | |||
| + | sudo systemd-resolve --statistics | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | ### Flush DNS / Clear cache | ||
| + | |||
| + | |||
| + | Vider le cache DNS SystemD | ||
| + | ~~~bash | ||
| + | systemd-resolve --flush-caches | ||
| + | ~~~ | ||
| + | |||
| + | Clear BIND Server DNS Cache | ||
| + | ~~~bash | ||
| + | sudo rndc restart | ||
| + | ~~~ | ||
| + | |||
| + | Clear DNS cache for a particular domain, use the below command. | ||
| + | ~~~bash | ||
| + | sudo rndc flushname < | ||
| + | ~~~ | ||
| + | |||
| + | Clear the dnsmasq Server DNS Cache | ||
| + | ~~~bash | ||
| + | sudo systemctl restart dnsmasq | ||
| + | ~~~ | ||
| + | |||
| + | Flush nscd server DNS Cache | ||
| + | ~~~bash | ||
| + | sudo systemctl restart nscd | ||
| + | ~~~ | ||
| + | |||
| + | pdnsd | ||
| + | ~~~bash | ||
| + | pdnsd-ctl empty-cache | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Options | ||
| + | |||
| + | No ipv6 AAAA | ||
| + | ~~~ | ||
| + | # since glibc 2.36 | ||
| + | options | ||
| + | ~~~ | ||
| + | |||
| + | Voir aussi AAAA vs A6 | ||
| + | |||
| + | no-tld-query (since glibc 2.14) | ||
| + | |||
| + | |||
| + | ## Pb | ||
| + | |||
| + | ### Pb Résolution noms courts | ||
| + | |||
| + | `/ | ||
| + | ~~~bash | ||
| + | # options rotate timeout:1 retries:1 | ||
| + | # options rotate timeout:2 attempts: 1 | ||
| + | options | ||
| + | nameserver | ||
| + | nameserver | ||
| + | search | ||
| + | domain | ||
| + | ~~~ | ||
| + | |||
| + | Résolution FQDN OK | ||
| + | ~~~ | ||
| + | # getent hosts srv01.domain1.local | ||
| + | 192.168.1.101 | ||
| + | ~~~ | ||
| + | |||
| + | Résolution FQDN NOK | ||
| + | ~~~ | ||
| + | # getent hosts srv01 | ||
| + | # | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | #### Solution | ||
| + | |||
| + | Placer `search` après `domain` ou alors commenter `domain` | ||
| + | |||
| + | According to the implementation of Glibc, if `domain` and `search` directives are both used, only the last instance will be used for DNS queries. \\ | ||
| + | Source : https:// | ||
| + | |||
| + | The `domain` directive is an obsolete name for the `search` directive that handles one search list entry only. \\ | ||
| + | Source : https:// | ||
| + | |||
| + | `/ | ||
| + | ~~~bash | ||
| + | options rotate timeout:1 retries:1 | ||
| + | # options rotate timeout:2 attempts: 1 | ||
| + | nameserver | ||
| + | nameserver | ||
| + | domain | ||
| + | search | ||
| + | ~~~ | ||
| + | |||
| + | ~~~ | ||
| + | # getent hosts srv01 | ||
| + | 192.168.1.101 | ||
| + | |||
| + | # getent hosts srv01.domain1.local | ||
| + | 192.168.1.101 | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ### Pb client DNS Linux résolution FQDN KO | ||
| + | |||
| + | ~~~bash | ||
| + | $ getent hosts plop | ||
| + | 192.168.21.25 | ||
| + | |||
| + | $ getent hosts plop.acme.local | ||
| + | $ | ||
| + | |||
| + | $ dig +short plop.acme.local | ||
| + | 192.168.21.25 | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | #### Solution | ||
| + | |||
| + | Vérif avec dig / nslookup et si OK le pb est ailleurs, par exemple dans la conf **libc** | ||
| + | |||
| + | `/ | ||
| + | ~~~ | ||
| + | # | ||
| + | hosts: | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | ## Outils | ||
| + | |||
| + | |||
| + | ### Dig | ||
| + | |||
| + | the step-by-step name resolution, you can do this: | ||
| + | ~~~bash | ||
| + | dig +add +trace @8.8.8.8 www.google.com | ||
| + | ~~~ | ||
| + | |||
| + | ### kdig | ||
| + | |||
| + | kdig client (part of Knot): | ||
| + | |||
| + | kdig +tls @localhost -p 8353 foobar.test | ||
| + | |||
| + | |||
| + | ### check-soa | ||
| + | |||
| + | https:// | ||
| + | |||
| + | ### blaeu-resolve | ||
| + | |||
| + | ~~~bash | ||
| + | blaeu-resolve -r 100 - -type NS meteofrance.com | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | -------------- | ||
| + | |||
| + | ## Notes client DNS & diag | ||
| + | |||
| + | ~~~bash | ||
| + | # / | ||
| + | sudo systemctl restart systemd-resolved.service | ||
| + | ~~~ | ||
| + | |||
| + | Conf | ||
| + | ~~~bash | ||
| + | systemd-resolve --set-dns=192.168.1.1 -i wlan1 | ||
| + | ~~~ | ||
| + | |||
| + | Status | ||
| + | ~~~bash | ||
| + | systemd-resolve --status | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | Disable and stop the systemd-resolved service | ||
| + | ~~~bash | ||
| + | sudo systemctl disable systemd-resolved.service | ||
| + | sudo systemctl stop systemd-resolved | ||
| + | ~~~ | ||
| + | |||
| + | `/ | ||
| + | ~~~ini | ||
| + | [main] | ||
| + | dns=default | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | unlink / | ||
| + | sudo service network-manager restart | ||
| + | ~~~ | ||
| + | |||
| + | DHCP DNS ? | ||
| + | |||
| + | `/ | ||
| + | ~~~ini | ||
| + | [DHCP] | ||
| + | UseDNS=true | ||
| + | ~~~ | ||
| + | |||
| + | Autre | ||
| + | ~~~bash | ||
| + | ps aux | grep dnsmasq | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | ### Diag port ? | ||
| + | |||
| + | `resolv.py` | ||
| + | ~~~python | ||
| + | import socket | ||
| + | for x in range(5): | ||
| + | | ||
| + | ~~~ | ||
| + | |||
| + | ~~~ | ||
| + | # strace -e trace=connect python resolv.py 2>&1 | grep 53 | ||
| + | connect(3, {sa_family=AF_INET, | ||
| + | connect(3, {sa_family=AF_INET, | ||
| + | connect(3, {sa_family=AF_INET, | ||
| + | connect(3, {sa_family=AF_INET, | ||
| + | connect(3, {sa_family=AF_INET, | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | ~~~bash | ||
| + | lsof -i udp:53 | ||
| + | time tcpdump udp port 53 -Qout -n | nl | ||
| + | time strace -f -e trace=%network -p 29976 2>&1 | grep ' | ||
| + | ~~~ | ||
| + | |||
| + | ~~~ | ||
| + | # sysdig -c lsof "' | ||
| + | COMMAND | ||
| + | systemd-resolve | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | csysdig -v connections fd.ip=10.172.93.224 | ||
| + | iftop -f "host 10.172.93.224" | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Autres | ||
| + | |||
| + | windows | ||
| + | |||
| + | ~~~ | ||
| + | nslookup | ||
| + | set detail | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Todo | ||
| + | |||
| + | Root serveur. | ||
| + | MX | ||
| + | Transfer de zone. | ||
| + | [[audit]] | ||
| + | |||
| + | ------- | ||
| + | |||
| + | https:// | ||
| + | |||
| + | ~~~bash | ||
| + | check-soa -i dz | ||
| + | ~~~ | ||
| + | |||
