apt-get install bind9 bind9utils bind9-doc
Éditer le fichier « options » (attention : acl internal ip publique si message 'GOT Recursion not available')
vi /etc/bind/named.conf.options
//Autoriser les IP locales à accéder au service DNS
acl internal { 127.0.0.0/24; ip publique; 192.168.100.0/24; };
options {
directory “/var/cache/bind”;//recursion yes;
allow-recursion { internal; };
allow-query { internal; };//Si le serveur doit interroger un DNS externe, renseigner la ou les IP ici :
forwarders {
80.67.169.12;
80.67.169.40;
};auth-nxdomain no; # conform to RFC1035
};
Relancer le service
systemctl restart bind9
Éditer le fichier principal de configuration :
vi /etc/bind/named.conf
include “/etc/bind/named.conf.options”;
include “/etc/bind/named.conf.local”;
include “/etc/bind/named.conf.default-zones”;
Éditer le fichier local de configuration :
vi /etc/bind/named.conf.local
zone “zone.domaine.fr” {
type master;
file “/etc/bind/host.zone.domaine.fr”;
allow-query { any; };};
zone “100.168.192.in-addr.arpa” {
type master;
file “/etc/bind/rev.zone.domaine.fr”;
allow-query { any; };
};
Éditer les fichiers de zones (host et rev) :
Attention au “Serial”
- Fichier hosts
vi /etc/bind/host.zone.domaine.fr
$TTL 86400
@ IN SOA node1.zone.domaine.fr. root.node1.zone.domaine.fr. (
2016120308 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ;Minimum TTL
)
@ IN NS node1.zone.domaine.fr.; On commence ici
node1 IN A 192.168.100.1
node2 IN A 192.168.100.2
node3 IN A 192.168.100.3; C’est fini !
- Fichier rev
vi /etc/bind/rev.zone.domaine.fr
$TTL 86400
@ IN SOA node1.zone.domaine.fr. root.node1.zone.domaine.fr. (2016120308 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ;Minimum TTL
)
@ IN NS node1.zone.domaine.fr.
node1 IN A 192.168.100.1
; On commence ici1 IN PTR node1.zone.domaine.fr.
2 IN PTR node2.zone.domaine.fr.
3 IN PTR node3.zone.domaine.fr.; C’est fini !
Donner les droits au dossier de configuration de Bind9
:
chmod -R 755 /etc/bind
chown -R bind:bind /etc/bind
Vérifier la configuration :
named-checkconf /etc/bind/named.conf
named-checkconf /etc/bind/named.conf.local
named-checkzone zone.domaine.fr /etc/bind/host.zone.domaine.fr
Doit renvoyer
zone zone.domaine.fr/IN: loaded serial 2016120308
OK
named-checkzone zone.domaine.fr /etc/bind/rev.zone.domaine.fr
Doit renvoyer
zone zone.domaine.fr/IN: loaded serial 2016120308
OK
Configurer les interfaces réseau
vi /etc/network/interfaces
# The secondary network interface
auto enp8s0f1
iface enp8s0f1 inet static
address 192.168.100.1
netmask 255.255.255.0
network 192.168.100.0
broadcast 192.168.100.255
gateway 192.168.100.1
# dns-* options are implemented by the resolvconf package, if installed
dns-search zone.domaine.fr
dns-nameservers 192.168.100.1#The primary network interface
#Ici notre attribution IP de l’interface réseau « externe » se fait via le serveur DHCP du service.
auto enp8s0f0
iface enp8s0f0 inet dhcp
Relancer le service :
systemctl restart bind9
Vérifier le fichier /etc/resolv.conf
search zone.domaine.fr domaine.fr
nameserver 192.168.100.1
Verifier que le serveur DNS fonctionne :
nslookup node2
nslookup node3
nslookup 192.168.100.3
nslookup 192.168.100.2