On considère que l’on a un Bind bien configuré (voir post précédent). On souhaite maintenant avoir aussi des zones maitres avec un enregistrement automatique des postes (window xp principalement!) dans le DNS !
Le DNS (la machine est « mondns » 192.168.1.3) n’est pas sur la même machine que le DHCP (la machine est « mondhcp » 192.168.1.4)
Sur la machine DNS, on configure la clé rndc avec le script adapté :
# rndc-confgen
On obtient de quoi concevoir le fichier /etc/bind/rndc.conf c’est à dire :
1 2 3 4 5 6 7 8 9 10 11 12 | # Start of rndc.conf
key "rndc-key" {
algorithm hmac-md5;
secret "monsecret";
};
options {
default-key "rndc-key";
default-server 127.0.0.1;
default-port 953;
};
# End of rndc.conf |
On rajoute dans le named.conf :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | key "rndc-key" {
algorithm hmac-md5;
secret "monsecret";
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1;192.168.1.4; } keys { rndc-key; };
};
# De quoi journaliser car cela ne fait pas de mal :
logging {
channel update_debug {
file "/var/log/update_debug.log" versions 3 size 100k;
severity debug 3;
print-category yes;
print-severity yes;
print-time yes;
};
channel security_info {
file "/var/log/securite_debug.log" versions 3 size 100k;
severity info;
print-category yes;
print-severity yes;
print-time yes;
};
channel queries_info {
file "/var/log/queries_debug.log" versions 3 size 1m;
severity debug 1;
print-category yes;
print-severity yes;
print-time yes;
};
channel lame_info {
file "/var/log/lame_debug.log" versions 3 size 100k;
severity info;
print-category yes;
print-severity yes;
print-time yes;
};
category update { update_debug; };
category security { security_info; };
category queries { queries_info; };
category lame-servers { lame_info; };
};
zone "domaine1.univ-orleans.fr" in {
type master;
file "/etc/namedb/db.domaine1.univ-orleans.fr";
allow-update{key rndc-key;};
notify yes;
};
zone "1.168.192.in-addr.arpa" in {
type master;
file "/etc/namedb/db.1.168.192";
allow-update{key rndc-key;};
notify yes;
}; |
Sur le serveur DHCP (dans dhcpd.conf) on rajoute :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ddns-domainname "domaine1.univ-orleans.fr.";
ddns-rev-domainname "in-addr.arpa.";
ddns-updates on;
ddns-update-style interim;
ignore client-updates;
update-static-leases on;
option domain-name-servers 192.168.1.3;
key "rndc-key" {
algorithm hmac-md5;
secret "monsecret";
};
zone 1.168.192.in-addr.arpa {
primary 192.168.1.3;
key rndc-key;
}
zone domaine1.univ-orleans.fr {
primary 192.168.1.3;
key rndc-key;
} |
Création de db.domaine1.univ-orleans.fr (on y met quelques machines…) :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | $ORIGIN .
$TTL 3600 ; 1 hour
domaine1.univ-orleans.fr IN SOA mondns.domaine1.univ-orleans.fr. administrateur.mondns.univ-orleans.fr. (
2731 ; serial
900 ; refresh (15 minutes)
600 ; retry (10 minutes)
86400 ; expire (1 day)
3600 ; minimum (1 hour)
)
NS mondns.domaine1.univ-orleans.fr.
$ORIGIN domaine1.univ-orleans.fr.
$TTL 21600 ; 6 hours
$TTL 3600 ; 1 hour
mondns A 192.168.1.3
$TTL 1200 ; 20 minutes
machine1 A 192.168.1.100
machine2 A 192.168.1.101 |
Création de db.1.168.192 :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | $ORIGIN .
$TTL 3600 ; 1 hour
1.168.192.in-addr.arpa IN SOA mondns.domaine1.univ-orleans.fr. administrateur.domaine1.univ-orleans.fr. (
47 ; serial
900 ; refresh (15 minutes)
600 ; retry (10 minutes)
86400 ; expire (1 day)
3600 ; minimum (1 hour)
)
NS mondns.domaine1.univ-orleans.fr.
$ORIGIN 1.168.192.in-addr.arpa.
$TTL 21600 ; 6 hours
3 PTR mondns.domaine1.univ-orleans.fr.
100 PTR machine1.domaine1.univ-orleans.fr.
101 PTR machine2.domaine1.univ-orleans.fr. |
On lance (ou relance) le démon :
# invoke-rc.d bind9 restart
Après quelques minutes (et si tout est OK dans /var/log/syslog et /chroot/named/var/log/) des fichiers .jnl doivent automatiquement se créer : db.1.168.192.jnl et db.domaine1.univ-orleans.fr.jnl !!
On peut aussi regarder dans les logs du DHCP (/var/log/syslog) sur la machine 192.168.1.4 :
1 2 3 4 | May 19 12:08:20 mondhcp dhcpd: DHCPDISCOVER from 00:15:d5:59:02:ba via eth0 May 19 12:08:20 mondhcp dhcpd: DHCPOFFER on 192.168.1.102 to 00:15:d5:59:02:ba via eth0 May 19 12:08:20 mondhcp dhcpd: Added new forward map from machine3.domaine1.univ-orleans.fr. to 192.168.1.102 May 19 12:08:20 mondhcp dhcpd: added reverse map from 102.1.168.192.in-addr.arpa. to machine3.domaine1.univ-orleans.fr. |
On peut constater que ça marche plutôt pas mal!
Un petit nslookup sur une machine ayant le resolv.conf configuré comme il faut avec le DNS que l’on vient de créer :
1 2 3 4 5 | # nslookup 192.168.1.102 Server: 192.168.1.3 Address: 192.168.1.3#53 102.1.168.192.in-addr.arpa name = machine3.domaine1.univ-orleans.fr. |
Tout est ok !