Esta é uma pergunta de acompanhamento para minha pergunta anterior . Abaixo está o /etc/unbound/unbound.conf
arquivo:
# unbound.conf(5) config file for unbound(8).
server:
directory: "/etc/unbound"
username: "unbound"
chroot: ""
logfile: "/etc/unbound/unbound.log"
pidfile: "/etc/unbound/unbound.pid"
verbosity: 1
# listen on all interfaces and answer queries from the local port 3000.
interface: 0.0.0.0
interface: ::0
port: 3000
access-control: 10.0.0.0/8 allow
#access-control: 2001:DB8::/64 allow
Com unbound.service
iniciado, tentei dig
um domínio através do servidor local não vinculado:
root@DNS:/etc/unbound# dig example.com A @192.168.1.50 -p 3000
; <<>> DiG 9.18.28-0ubuntu0.24.04.1-Ubuntu <<>> example.com A @192.168.1.50 -p 3000
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 8367
;; flags: qr rd ad; QUERY: 0, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; Query time: 0 msec
;; SERVER: 192.168.1.50#3000(192.168.1.50) (UDP)
;; WHEN: Tue Oct 29 16:18:19 UTC 2024
;; MSG SIZE rcvd: 12
Não entendo por que WARNING: recursion requested but not available
unbound é configurado para ser um resolvedor recursivo por padrão. Também. SERVER: 192.168.1.50#3000(192.168.1.50) (UDP)
mostra que unbound foi usado, no entanto, ele falhou em obter o domínio. O que está errado e como eu conserto esse problema?
Abaixo mostramos a resposta via systemd-resolved.service
servidor stub:
root@DNS:/etc/unbound# dig example.com
; <<>> DiG 9.18.28-0ubuntu0.24.04.1-Ubuntu <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36356
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;example.com. IN A
;; ANSWER SECTION:
example.com. 3304 IN A 93.184.215.14
;; Query time: 12 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Tue Oct 29 16:43:59 UTC 2024
;; MSG SIZE rcvd: 56
Atualizar:
Após corrigir a sub-rede, como mencionado pela resposta de @mpboden, o dig
comando só funcionou uma vez. Por que esse é o caso?
root@DNS:/etc/unbound/unbound.conf.d# systemctl start unbound.service
root@DNS:/etc/unbound/unbound.conf.d# [1730230920] unbound[5780:0] notice: init module 0: subnetcache
[1730230920] unbound[5780:0] notice: init module 1: validator
[1730230920] unbound[5780:0] notice: init module 2: iterator
[1730230921] unbound[5780:0] info: start of service (unbound 1.19.2).
root@DNS:/etc/unbound/unbound.conf.d# dig example.com A @192.168.1.50 -p 3000
; <<>> DiG 9.18.28-0ubuntu0.24.04.1-Ubuntu <<>> example.com A @192.168.1.50 -p 3000
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40273
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;example.com. IN A
;; ANSWER SECTION:
example.com. 3600 IN A 93.184.215.14
;; Query time: 712 msec
;; SERVER: 192.168.1.50#3000(192.168.1.50) (UDP)
;; WHEN: Tue Oct 29 19:42:34 UTC 2024
;; MSG SIZE rcvd: 56
root@DNS:/etc/unbound/unbound.conf.d# dig google.com A @192.168.1.50 -p 3000
; <<>> DiG 9.18.28-0ubuntu0.24.04.1-Ubuntu <<>> google.com A @192.168.1.50 -p 3000
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 49774
;; flags: qr rd ad; QUERY: 0, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; Query time: 0 msec
;; SERVER: 192.168.1.50#3000(192.168.1.50) (UDP)
;; WHEN: Tue Oct 29 19:42:56 UTC 2024
;; MSG SIZE rcvd: 12
root@DNS:/etc/unbound/unbound.conf.d# dig example.com A @192.168.1.50 -p 3000
; <<>> DiG 9.18.28-0ubuntu0.24.04.1-Ubuntu <<>> example.com A @192.168.1.50 -p 3000
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 46236
;; flags: qr rd ad; QUERY: 0, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; Query time: 0 msec
;; SERVER: 192.168.1.50#3000(192.168.1.50) (UDP)
;; WHEN: Tue Oct 29 19:43:36 UTC 2024
;; MSG SIZE rcvd: 12
Vejo que você definiu o seguinte:
access-control: 10.0.0.0/8 allow
Mas sua sub-rede é
192.168.1.0/24
. Altere esta linha para:access-control: 192.168.1.0/24 allow
Isso permitirá que o unbound aceite consultas DNS da rede 192.168.1.0/24.