Introduzione
Unbound è un server DNS di convalida, ricorsivo e di memorizzazione nella cache. Detto questo, il server DNS non associato non può essere utilizzato come server DNS autorevole, il che significa che non può essere utilizzato per ospitare record di nomi di dominio personalizzati. Di conseguenza, se il tuo obiettivo è creare un server DNS di sola cache o di inoltro, Unbound potrebbe essere la tua scelta preferita, poiché fa proprio questo e lo fa bene.
Obiettivo
L'obiettivo è fornire una guida di installazione e configurazione rapida e facile da seguire per il server DNS di solo cache Unbound su Redhat 7 Linux. Alla fine di questa guida sarai in grado di utilizzare il server DNS Unbound da tutti i client sulla tua rete locale.
Requisiti
Accesso privilegiato al tuo server Redhat 7 Linux con repository RedHat standard configurati.
Difficoltà
MEDIO
Convenzioni
- # – richiede che i comandi linux dati vengano eseguiti con i privilegi di root direttamente come utente root o usando
sudo
comando - $ – richiede che i comandi linux dati vengano eseguiti come un normale utente non privilegiato
Istruzioni
Installazione degli strumenti DNS e non associati
Nel primo passaggio installeremo l'effettivo server DNS non associato e gli strumenti DNS che verranno eventualmente utilizzati per testare la configurazione del server solo cache DNS. Dato che hai il tuo repository Redhat configurato correttamente, puoi installarli entrambi eseguendo il seguente comando linux:
# yum install unbound bind-utils
Configurazione di base non associata
Ora eseguiremo una configurazione di base del server di sola memorizzazione nella cache DNS non associato. Questo verrà fatto modificando il file di configurazione di Unbound /etc/unbound/unbound.conf
utilizzando l'editor di testo o utilizzando un sed
sottostante comandi. Innanzitutto, usa il tuo editor di testo preferito per individuare la riga # interface: 0.0.0.0
e decommentalo rimuovendo il #
iniziale cartello. In alternativa, usa il seguente sed
comando:
# sed -i '/interface: 0.0.0.0$/s/#//' /etc/unbound/unbound.conf
La configurazione precedente indicherà al server DNS non associato l'ascolto su tutte le interfacce di rete locali. Quindi, consenti ai tuoi client LAN di interrogare la cache di Unbound. Individua la riga pertinente modifica l'indirizzo IP di loopback predefinito 127.0.0.0/8
all'indirizzo di rete della tua LAN es. 10.0.0.0/24
:
FROM: access-control: 127.0.0.0/8 allow TO access-control: 10.0.0.0/24 allow
Quanto sopra può essere fatto anche da sed
comando:
# sed -i 's/127.0.0.0\/8 allow/10.0.0.0\/24 allow/' /etc/unbound/unbound.conf
Imposta il supporto DNSSEC
Successivamente, indichiamo al server DNS non associato di generare chiavi RSA per fornire supporto DNSSEC:
# unbound-control-setup setup in directory /etc/unbound generating unbound_server.key Generating RSA private key, 1536 bit long modulus .................++++ .........++++ e is 65537 (0x10001) generating unbound_control.key Generating RSA private key, 1536 bit long modulus .........++++ ..................................++++ e is 65537 (0x10001) create unbound_server.pem (self signed certificate) create unbound_control.pem (signed client certificate) Signature ok subject=/CN=unbound-control Getting CA Private Key Setup success. Certificates created. Enable in unbound.conf file to use
Non resta che controllare la configurazione di Unbound:
# unbound-checkconf unbound-checkconf: no errors in /etc/unbound/unbound.conf
Abilita e avvia il server Unbound
A questo punto abiliteremo l'avvio del server DNS non associato all'avvio:
# systemctl enable unbound Created symlink from /etc/systemd/system/multi-user.target.wants/unbound.service to /usr/lib/systemd/system/unbound.service.
e avvia il servizio vero e proprio:
# service unbound start Redirecting to /bin/systemctl start unbound.service
Assicurati che il server DNS non associato sia in esecuzione controllandone lo stato:
[root@localhost unbound]# service unbound status Redirecting to /bin/systemctl status unbound.service ● unbound.service - Unbound recursive Domain Name Server Loaded: loaded (/usr/lib/systemd/system/unbound.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2016-12-07 10:32:58 AEDT; 6s ago Process: 2355 ExecStartPre=/usr/sbin/unbound-anchor -a /var/lib/unbound/root.key -c /etc/unbound/icannbundle.pem (code=exited, status=0/SUCCESS) Process: 2353 ExecStartPre=/usr/sbin/unbound-checkconf (code=exited, status=0/SUCCESS) Main PID: 2357 (unbound) CGroup: /system.slice/unbound.service └─2357 /usr/sbin/unbound -d Dec 07 10:32:57 localhost.localdomain systemd[1]: Starting Unbound recursive Domain Name Server... Dec 07 10:32:57 localhost.localdomain unbound-checkconf[2353]: unbound-checkconf: no errors in /etc/unbound/unbound.conf Dec 07 10:32:58 localhost.localdomain systemd[1]: Started Unbound recursive Domain Name Server. Dec 07 10:32:58 localhost.localdomain unbound[2357]: Dec 07 10:32:58 unbound[2357:0] warning: increased limit(open files) from 1024 to 8266 Dec 07 10:32:58 localhost.localdomain unbound[2357]: [2357:0] notice: init module 0: validator Dec 07 10:32:58 localhost.localdomain unbound[2357]: [2357:0] notice: init module 1: iterator Dec 07 10:32:58 localhost.localdomain unbound[2357]: [2357:0] info: start of service (unbound 1.4.20).
Apri la porta del firewall DNS
Per consentire ai tuoi client LAN locali di connettersi al tuo nuovo server DNS di sola cache Unbound, dovrai aprire una porta DNS:
# firewall-cmd --permanent --add-service dns success # firewall-cmd --reload success
Fatto tutto, ora siamo pronti per il test.
Test
Infine, siamo arrivati a un punto in cui possiamo eseguire alcuni test di base del nostro nuovo server di solo cache DNS Unbound. Per questo utilizziamo dig
comando che fa parte di bind-utils
precedentemente installato pacchetto per eseguire alcune query DNS. Innanzitutto, esegui la query DNS sul server DNS effettivo:
# dig @localhost example.com ; <<>> DiG 9.9.4-RedHat-9.9.4-37.el7 <<>> @localhost example.com ; (2 servers found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53485 ;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;example.com. IN A ;; ANSWER SECTION: example.com. 86400 IN A 93.184.216.34 ;; Query time: 817 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Wed Dec 07 10:40:46 AEDT 2016 ;; MSG SIZE rcvd: 56
Si noti che il tempo di query è superiore a 817 msec. Poiché abbiamo configurato il server solo cache DNS, questa query è ora memorizzata nella cache, quindi qualsiasi successiva risoluzione della query DNS dello stesso nome di dominio sarà piuttosto immediata:
# dig @localhost example.com ; <<>> DiG 9.9.4-RedHat-9.9.4-37.el7 <<>> @localhost example.com ; (2 servers found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34443 ;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;example.com. IN A ;; ANSWER SECTION: example.com. 86272 IN A 93.184.216.34 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Wed Dec 07 10:42:54 AEDT 2016 ;; MSG SIZE rcvd: 56
Infine, ora puoi testare la configurazione del server DNS Ubound dai tuoi client LAN locali puntandoli all'indirizzo IP di Unbound, ad es. 10.1.1.45:
$ dig @10.1.1.45 example.com ; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> @10.1.1.45 example.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 50494 ;; flags: qr rd ad; QUERY: 0, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 ;; WARNING: recursion requested but not available ;; Query time: 0 msec ;; SERVER: 10.1.1.45#53(10.1.1.45) ;; WHEN: Wed Dec 07 10:45:43 AEDT 2016 ;; MSG SIZE rcvd: 12