Installer un Serveur DNS sur debian (raspberry Pi)

DNS server installation debian

machine 3littlehills 192.168.10.111 passerelle 192.168.10.1

Modification de l'environnement existant

Modifier les fichiers hostnameet hosts pour introduire ne nom de la zone.

sudo jed /etc/hostname
cat /etc/hostname
#
3littlehills.raspinet
sudo jed /etc/hosts
cat /etc/hosts
#
127.0.0.1       localhost
127.0.1.1       3littlehills.raspinet 3littlehills
192.168.10.111  3littlehills.raspinet 3littlehills

::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

Mettre à jour les paquets sudo apt updatepuis installer bind9 sudo apt install bind9 dnsutils modifier le fichier /etc/systemd/resolved.conf afin que le fichier /etc/resolv.confprenne en compte la nouvelle zone.

sudo jed /etc/systemd/resolved.conf
cat /etc/systemd/resolved.conf
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details

[Resolve]
# Some examples of DNS servers which may be used for DNS= and FallbackDNS=:
# Cloudflare: 1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001
# Google:     8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
# Quad9:      9.9.9.9 2620:fe::fe
DNS=192.168.10.1 9.9.9.9 2620:fe::fe
FallbackDNS=9.9.9.9 2620:fe::fe
Domains=raspinet
#DNSSEC=no
#DNSOverTLS=no
#MulticastDNS=yes
#LLMNR=yes
#Cache=yes
#DNSStubListener=yes
#DNSStubListenerExtra=
#ReadEtcHosts=yes
#ResolveUnicastSingleLabel=no

Configuration de bind

Accéder au dossier de configuration de bind modifier les fichiers de configuration puis ajouter les fichiers de définition de la nouvelle zone cd /etc/bind.

sudo cp named.conf.local named.conf.local-orig
sudo jed named.conf.local
cat named.conf.local
#
//
// 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 "raspinet" {
    type master;
    file "/etc/bind/db.raspinet";
};

zone "10.168.192.in-addr.arpa" {
    type master;
    file "/etc/bind/db.1O.168.192.in-addr.arpa";
};
sudo jed db.raspinet
#
$TTL 10800
$ORIGIN raspinet.
@       IN SOA 3littlehills.raspinet. root.raspinet. (
        20220710;
        3h;
        1h;
        1w;
        1h);
@       IN NS 3littlehills.raspinet.
3littlehills          IN A 192.168.10.111
host            IN A 192.168.10.1
sudo jed db.1O.168.192.in-addr.arpa
#
$TTL 10800
$ORIGIN 10.168.192.in-addr.arpa.
@       IN SOA 3littlehills.raspinet. root.raspinet. (
        20220710;
        3h;
        1h;
        1w;
        1h);
@       IN NS 3littlehills.raspinet.
132     IN PTR 3littlehills.raspinet.
1       IN PTR host.raspinet.

Vérifier le fonctionnement du dispositif avec named-checkconf -z.

zone raspinet/IN: loaded serial 20220710
zone 10.168.192.in-addr.arpa/IN: loaded serial 20220710
zone localhost/IN: loaded serial 2
zone 127.in-addr.arpa/IN: loaded serial 1
zone 0.in-addr.arpa/IN: loaded serial 1
zone 255.in-addr.arpa/IN: loaded serial 1

Commentaires