Vous n'êtes pas identifié(e).
L'icône rouge permet de télécharger chaque page du wiki visitée au format
PDF et la grise au format ODT →
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révision Les deux révisions suivantes | ||
atelier:chantier:dns-bind9-sur-wheezy [01/09/2014 09:19] Hypathie [Installer un server DNS en local bind9] |
atelier:chantier:dns-bind9-sur-wheezy [01/09/2014 09:27] Hypathie [Côté client] |
||
---|---|---|---|
Ligne 140: | Ligne 140: | ||
*éventuellement des options | *éventuellement des options | ||
- | |||
- | =====Configurer un server DNS Maître en local sous wheezy===== | ||
- | Il s'agit d'un serveur qui ne fera autorité que sur le réseau local et non sur aucune autre zone.\\ | ||
- | Il va s'occuper d'aller chercher les infos sur des forwarders ou des serveurs racine ... et de les stoker dans son cache. | ||
- | |||
- | *Soit un server sous Debian Wheezy nommé : "debian-serveur" | ||
- | *Adresse IP pour "eth0 " du serveur "debian-serveur" : 192.168.0.14 | ||
- | *Soit un nom de domaine : "mondomaine.hyp" | ||
- | *Soit un ordi client sur le réseau local : "debian-client" avec l'IP 192.168.0.22 | ||
- | ====Pré-requis==== | ||
- | ===IP statique=== | ||
- | * Configurer une IP statique pour le serveur sur lequel on installe bind9. | ||
- | Se rendre sur le site de son FAI, et associer l'adresse mac du serveur à l'IP dans les BAUX/DHCP. | ||
- | |||
- | ===Compléter /etc/hostname === | ||
- | |||
- | <code root>vim /etc/hostname </code> | ||
- | <code>debian-serveur.mondomaine.hyp</code> | ||
- | |||
- | <code root>/etc/init.d/hostname.sh start</code> | ||
- | |||
- | ===Compléter /etc/host.conf=== | ||
- | |||
- | <code root>vim /etc/host.conf </code> | ||
- | <code>order hosts, bind | ||
- | multi on | ||
- | </code> | ||
- | |||
- | ===Compléter /etc/hosts=== | ||
- | |||
- | <code root>vim /etc/hosts</code> | ||
- | |||
- | <code> | ||
- | 127.0.0.1 localhost.localdomain localhost | ||
- | |||
- | 192.168.0.14 serveur-debian.mondomaine.hyp serveur-debian | ||
- | 192.168.0.22 debian.mondomaine.hyp debian | ||
- | |||
- | 192.168.0.1 gateway.modomaine.hyp gateway | ||
- | |||
- | |||
- | # The following lines are desirable for IPv6 capable hosts | ||
- | ::1 localhost ip6-localhost ip6-loopback | ||
- | ff02::1 ip6-allnodes | ||
- | ff02::2 ip6-allrouters | ||
- | </code> | ||
- | |||
- | ===Déclarer un nom de domaine dans /etc/resolv.conf=== | ||
- | If faut déclarer un nom de domaine dans /etc/resolv.conf.\\ | ||
- | Au passage on peut indiquer d'autre DNS extérieurs que ceux du FAI.\\ | ||
- | Il faut pour que la nouvelle configuration du fichier /etc/resolv.conf ne soit par effacer lors d'un redémarrage, par networmanager créer un script.\\ | ||
- | <note tip> | ||
- | * Voir : [[https://wiki.debian.org/fr/NetworkConfiguration#Configuration_de_DNS_pour_network-manager]] | ||
- | |||
- | * Attention la suppression de networkmanager déstabilise le système : | ||
- | |||
- | <code root>apt-get remove --purge network-manager-gnome netwok-manager</code> | ||
- | |||
- | </note> | ||
- | |||
- | On peut soit éditer le fichier **/etc/resolv.conf**, mais comme le script suivant est nécessaire pour ne pas être embêté par networmanager, on va modifier le fichier avec le script. | ||
- | |||
- | * Création du script pour networkmanager : | ||
- | <code root>cd /etc/NetworkManager/</code> | ||
- | |||
- | <code root>touch /etc/NetworkManager/dispatcher.d/99-dns</code> | ||
- | |||
- | <code root>vim /etc/NetworkManager/dispatcher.d/99-dns</code> | ||
- | <code>#!/bin/sh | ||
- | echo "domain mondomaine.hyp" > /etc/resolv.conf | ||
- | echo "search mondomaine.hyp" >> /etc/resolv.conf | ||
- | echo "nameserver 127.0.0.1" >> /etc/resolv.conf | ||
- | echo "nameserver 8.8.8.8" >> /etc/resolv.conf | ||
- | echo "nameserver 8.8.4.4" >> /etc/resolv.conf</code> | ||
- | |||
- | >Adapter le contenu à la configuration | ||
- | |||
- | <code root>chmod 755 /etc/NetworkManager/dispatcher.d/99-dns</code> | ||
- | |||
- | * Exécution du script : | ||
- | |||
- | <code root>bash /etc/NetworkManager/dispatcher.d/99-dns</code> | ||
- | <code root>less /etc/resolv.conf</code> | ||
- | <code>domain mondomaine.hyp | ||
- | search mondomaine.hyp | ||
- | nameserver 127.0.0.1 | ||
- | nameserver 8.8.8.8 | ||
- | nameserver 8.8.4.4 | ||
- | </code> | ||
- | |||
- | |||
- | * Redémarrer le réseau : | ||
- | |||
- | <code root>/etc/init.d/networking start</code> | ||
- | |||
- | ====Installer et configurer bind ==== | ||
- | ===installation du paquetage=== | ||
- | <code root> | ||
- | apt-get update apt-get | ||
- | </code> | ||
- | |||
- | <code root> | ||
- | apt-get install bind9 | ||
- | </code> | ||
- | |||
- | ===Configuration de bind pour un serveur DNS maître local=== | ||
- | <note tip> | ||
- | __Quelques commandes utiles lors de la configuration de bind9__ : | ||
- | |||
- | * Si la configuration est difficile on peut chercher les erreurs avec les commandes suivantes : | ||
- | <code root>named-checkzone webadonf.lan /etc/bind/db.webadonf.lan</code> | ||
- | <code root>named-checkzone webadonf.lan /etc/bind/db.webadonf.lan.inv</code> | ||
- | <code root>named-checkconf /etc/bind/named.conf</code> | ||
- | <code root>named-checkconf /etc/bind/named.conf.options</code> | ||
- | |||
- | |||
- | *Voir aussi les logs : | ||
- | <code root>tail -30 /var/log/syslog</code> | ||
- | |||
- | </note> | ||
- | |||
- | *Le dossier **/etc/bind/** : | ||
- | |||
- | <code root>cd /etc/bind/ && ls</code> | ||
- | |||
- | <code>bind.keys db.127 db.empty db.root named.conf.default-zones named.conf.options zones.rfc1918 | ||
- | db.0 db.255 db.local named.conf named.conf.local rndc.key | ||
- | </code> | ||
- | |||
- | * Créer le fichier "**/etc/bind/db.mondomaine.hyp**" : | ||
- | |||
- | Prendre le fichier /etc/bind/db.local pour modèle. | ||
- | |||
- | <code root>cp /etc/bind/db.local /etc/bind/db.mondomaine.hyp</code> | ||
- | |||
- | Éditer "/etc/bind/db.mondomaine.hyp" : | ||
- | |||
- | <code root>vim /etc/bind/db.mondomaine.hyp</code> | ||
- | <code> | ||
- | ; | ||
- | ; BIND data file for local loopback interface | ||
- | ; | ||
- | $TTL 604800 | ||
- | @ IN SOA debian-serveur.mondomaine.hyp. root.mondomaine.hyp. ( | ||
- | 2 ; Serial | ||
- | 604800 ; Refresh | ||
- | 86400 ; Retry | ||
- | 2419200 ; Expire | ||
- | 604800 ) ; Negative Cache TTL | ||
- | ; | ||
- | @ IN NS debian-serveur.mondomaine.hyp. | ||
- | debian-serveur IN A 192.168.0.14 | ||
- | |||
- | </code> | ||
- | |||
- | * Créer le fichier de recherche inverse "**db.mondomaine.hyp.inv**" : | ||
- | |||
- | Prendre pour modèle /etc/bind/db.127 | ||
- | |||
- | <code root>cp /etc/bind/db.127 /etc/bind/db.192</code> | ||
- | |||
- | Éditer "/etc/bind/db.192" : | ||
- | |||
- | <code root>vim /etc/bind/db.192</code> | ||
- | <code> | ||
- | ; | ||
- | ; BIND reverse data file for eth0 interface | ||
- | ; | ||
- | $TTL 604800 | ||
- | @ IN SOA debian-serveur.mondomaine.hyp. root.mondomaine.hyp. ( | ||
- | 1 ; Serial | ||
- | 604800 ; Refresh | ||
- | 86400 ; Retry | ||
- | 2419200 ; Expire | ||
- | 604800 ) ; Negative Cache TTL | ||
- | ; | ||
- | @ IN NS debian-serveur. | ||
- | 14 IN PTR debian-serveur.mondomaine.hyp. | ||
- | |||
- | </code> | ||
- | |||
- | * Configurer le fichier "/etc/bind/named.conf.local" : | ||
- | <code root>vim /etc/bind/named.conf.local</code> | ||
- | <code> | ||
- | // | ||
- | // Do any local configuration here | ||
- | // | ||
- | |||
- | // Consider adding the 1918 zones here, if they are not used in your | ||
- | // organization | ||
- | //include "/etc/bind/zones.rfc1918"; | ||
- | zone "mondomaine.hyp" { | ||
- | type master; | ||
- | file "/etc/bind/db.mondomaine.hyp"; | ||
- | }; | ||
- | zone "0.168.192.in-addr.arpa" { | ||
- | type master; | ||
- | file "/etc/bind/db.192"; | ||
- | }; | ||
- | |||
- | </code> | ||
- | |||
- | * Configurer "/etc/bind/named.conf.options" : | ||
- | <code root>vim /etc/bind/named.conf.options</code> | ||
- | <code> | ||
- | options { | ||
- | directory "/var/cache/bind"; | ||
- | |||
- | // If there is a firewall between you and nameservers you want | ||
- | // to talk to, you may need to fix the firewall to allow multiple | ||
- | // ports to talk. See http://www.kb.cert.org/vuls/id/800113 | ||
- | |||
- | // If your ISP provided one or more IP addresses for stable | ||
- | // nameservers, you probably want to use them as forwarders. | ||
- | // Uncomment the following block, and insert the addresses replacing | ||
- | // the all-0's placeholder. | ||
- | |||
- | forwarders { | ||
- | 192.168.0.1; | ||
- | 8.8.8.8; | ||
- | 8.8.4.4; | ||
- | 212.27.40.240; | ||
- | 212.27.40.241; | ||
- | }; | ||
- | |||
- | //======================================================================== | ||
- | // If BIND logs error messages about the root key being expired, | ||
- | // you will need to update your keys. See https://www.isc.org/bind-keys | ||
- | //======================================================================== | ||
- | dnssec-validation auto; | ||
- | |||
- | auth-nxdomain no; # conform to RFC1035 | ||
- | version none; | ||
- | forward only; | ||
- | // listen-on-v6 { any; }; | ||
- | }; | ||
- | |||
- | |||
- | </code> | ||
- | |||
- | On peut mettre les forwarders qu'on souhaite, par exemple ici ceux de "boxmachin" fournisseur adsl. | ||
- | |||
- | * redémarrer bind9 : | ||
- | |||
- | <code root>service bind9 restart</code> | ||
- | |||
- | ou | ||
- | |||
- | <code root>/etc/init.d/bind9 restart</code> | ||
- | |||
- | <code> | ||
- | [....] Stopping domain name service...: bind9rndc: connect failed: 127.0.0.1#953: connection refused | ||
- | . ok | ||
- | [ ok ] Starting domain name service...: bind9. | ||
- | |||
- | </code> | ||
- | |||
- | ==== Vérifier le DNS==== | ||
- | Pour avoir le nom complet : | ||
- | <code root>hostname</code> | ||
- | <code> | ||
- | debian-serveur.mondomaine.hyp</code> | ||
- | |||
- | * Avec nslookup : | ||
- | <code root>nslookup</code> | ||
- | <code>> debian-serveur.mondomaine.hyp | ||
- | Server: 127.0.0.1 | ||
- | Address: 127.0.0.1#53 | ||
- | |||
- | Name: debian-serveur.mondomaine.hyp | ||
- | Address: 192.168.0.14 | ||
- | > exit</code> | ||
- | |||
- | * Idem pour la zone inverse : | ||
- | <code root>nslookup</code> | ||
- | <code>> 192.168.0.14 | ||
- | Server: 127.0.0.1 | ||
- | Address: 127.0.0.1#53 | ||
- | |||
- | 14.0.168.192.in-addr.arpa name = debian-serveur.mondomaine.hyp. | ||
- | > exit</code> | ||
- | |||
- | Il répond aux deux, donc tout va bien ! | ||
- | |||
- | *Avec dig : | ||
- | <code root>dig debian-serveur</code> | ||
- | |||
- | <code root>dig mondomaine.hyp</code> | ||
- | |||
- | <code root>/code>dig -x @192.168.0.14</code> | ||
- | |||
- | ====Interroger le DNS local sur un client du réseau ==== | ||
- | ===Configuration === | ||
- | <code root>vim /etc/bind/db.mondomaine.hyp</code> | ||
- | <code>; | ||
- | ; BIND data file for local loopback interface | ||
- | ; | ||
- | $TTL 604800 | ||
- | @ IN SOA debian-serveur.mondomaine.hyp. root.mondomaine.hyp. ( | ||
- | 2 ; Serial | ||
- | 604800 ; Refresh | ||
- | 86400 ; Retry | ||
- | 2419200 ; Expire | ||
- | 604800 ) ; Negative Cache TTL | ||
- | ; | ||
- | @ IN NS debian-serveur.mondomaine.hyp. | ||
- | debian-serveur IN A 192.168.0.14 | ||
- | debian-client1 IN A 192.168.0.22 | ||
- | </code> | ||
- | |||
- | Et pour la réserve inverse : | ||
- | |||
- | <code root>vim /etc/bind/db.192</code> | ||
- | <code>; | ||
- | ; BIND reverse data file for eth0 interface | ||
- | ; | ||
- | $TTL 604800 | ||
- | @ IN SOA debian-serveur.mondomaine.hyp. root.mondomaine.hyp. ( | ||
- | 1 ; Serial | ||
- | 604800 ; Refresh | ||
- | 86400 ; Retry | ||
- | 2419200 ; Expire | ||
- | 604800 ) ; Negative Cache TTL | ||
- | ; | ||
- | @ IN NS debian-serveur. | ||
- | 14 IN PTR debian-serveur.mondomaine.hyp. | ||
- | 22 IN PTR debian-client1. | ||
- | </code> | ||
- | |||
- | On recharge bind : | ||
- | <code root>/etc/init.d/bind9 restart</code> | ||
- | |||
- | ===Vérification=== | ||
- | <code root>nslookup</code> | ||
- | |||
- | <code> | ||
- | > debian-client1 | ||
- | Server: 127.0.0.1 | ||
- | Address: 127.0.0.1#53 | ||
- | |||
- | Name: debian-client1.mondomaine.hyp | ||
- | Address: 192.168.0.22 | ||
- | > 192.168.0.22 | ||
- | Server: 127.0.0.1 | ||
- | Address: 127.0.0.1#53 | ||
- | |||
- | 22.0.168.192.in-addr.arpa name = debian-client1. | ||
- | > exit</code> | ||
=====Configurer un server DNS Maître en local sous wheezy===== | =====Configurer un server DNS Maître en local sous wheezy===== | ||
Ligne 728: | Ligne 380: | ||
</code> | </code> | ||
- | On peut mettre les forwarders qu'on souhaite, par exemple ici ceux de google et/ou ceux de "boxmachin" fournisseur adsl. | + | On peut mettre les forwarders qu'on souhaite, par exemple ici ceux de google ou/et ceux de "boxmachin", fournisseur adsl. |
* Redémarrer bind9 : | * Redémarrer bind9 : | ||
Ligne 779: | Ligne 431: | ||
<code root>/code>dig -x @192.168.0.14</code> | <code root>/code>dig -x @192.168.0.14</code> | ||
- | ====Interroger le DNS local sur un client du réseau ==== | + | ====Interroger le server DNS local au sujet d'un client du réseau ==== |
===Configuration === | ===Configuration === | ||
<code root>vim /etc/bind/db.mondomaine.hyp</code> | <code root>vim /etc/bind/db.mondomaine.hyp</code> | ||
Ligne 836: | Ligne 488: | ||
22.0.168.192.in-addr.arpa name = debian-client1. | 22.0.168.192.in-addr.arpa name = debian-client1. | ||
> exit</code> | > exit</code> | ||
+ | |||
=====Côté client ===== | =====Côté client ===== | ||
- | Se débarrasser [[utilisateurs:hypathie:tutos:dns-bind?&#desactiver-networkmanager|de networkmanager]] avant tout.\\ | + | Installer le script pour networkmanager [[atelier:chantier:dns-bind9-sur-wheezy?&#declarer-un-nom-de-domaine-dans-etc-resolvconf|networkmanager]] avant tout.\\ |
- | *Il n'y a qu'un fichier à éditer "/etc/resolv.conf": | ||
- | |||
- | <code root>vim /etc/resolv.conf</code> | ||
- | |||
- | <code> | ||
- | domaine mondomaine.hyp | ||
- | search mondomaine.hyp | ||
- | nameserver 192.168.0.14 | ||
- | </code> | ||
* Puis recharger la configuration réseau : | * Puis recharger la configuration réseau : |