Open Bundy01 opened 2 years ago
The problem is the line where you include
the key file, at the start of your config. The key should be listed in an auto-trust-anchor-file or a trust-anchor-file clause.
Later on, you have both an auto-trust-anchor-file and a trust-anchor-file. Use only one of the two. They have different path names. Use the one that is the correct key and is writable for auto-trust-anchor-file.
Because of the include at the start, the config parser attempts to read that file. That prints the syntax errors.
I included the file because otherwise Unbound tries to create the file in etc/unbound/etc/trusted-key.key
instead of /etc/trusted-key.key
.
So whether directory: "/etc/unbound"
is commented out or not.
For the trust-anchor-file: "/etc/unbound/trusted-key.key"
line, I actually forgot to comment it out in the post.
I also tried to do this: auto-trust-anchor-file: "/etc/unbound/trusted-key.key"
but I have permission problems on the file (even giving read/write permission to all).
You should not do that include. The pathname change that you talk about is likely because of chroot, check the chroot setting it has a default and you do not list it in the config. The default depends on the distro you use, and that also sets in some cases lots of systemd settings, and permissions profiles, like apparmor, selinux. Those are likely interfering with the permissions. That is what you then need to solve, the permissions problem.
Thank you for the answer. I have disabled Apparmor's Unbound profile and uncommented the 'chroot' line without success on the rights. I won't insist here. However, I still have a question if you allow me. I use Unbound on my personal computer and I am the only user.
Can you tell me if I forgot to add security settings in the conf file? Or on the contrary, if I have added potential vulnerabilities?
server:
include: /etc/unbound/blacklist
verbosity: 0
statistics-interval: 0
num-threads: 8
interface: 127.0.0.1
interface: ::1
port: 53
outgoing-range: 78
so-rcvbuf: 0
so-sndbuf: 0
so-reuseport: yes
edns-buffer-size: 1232
stream-wait-size: 7m
msg-cache-size: 32m
msg-cache-slabs: 8
num-queries-per-thread: 1024
rrset-cache-size: 64m
rrset-cache-slabs: 8
cache-min-ttl: 86400
cache-max-ttl: 172800
infra-cache-slabs: 8
infra-cache-numhosts: 30000
do-ip4: yes
do-ip6: no
do-udp: yes
do-tcp: yes
use-systemd: no
access-control: 0.0.0.0/0 refuse
access-control: 127.0.0.0/8 allow
access-control: ::0/0 refuse
access-control: ::1/128 allow
chroot: "/etc/unbound"
username: "unbound"
directory: "/etc/unbound"
use-syslog: no
log-time-ascii: no
log-queries: no
log-replies: no
log-tag-queryreply: no
log-local-actions: no
log-servfail: no
root-hints: "root.hints"
hide-identity: yes
hide-version: yes
hide-http-user-agent: yes
harden-glue: yes
harden-dnssec-stripped: yes
harden-below-nxdomain: yes
harden-algo-downgrade: no
qname-minimisation: yes
aggressive-nsec: yes
use-caps-for-id: yes
private-address: 10.0.0.0/8
private-address: 192.168.0.0/16
private-address: fd00::/8
private-address: fe80::/10
private-address: ::ffff:0:0/96
unwanted-reply-threshold: 10000000
do-not-query-localhost: no
prefetch: yes
prefetch-key: yes
minimal-responses: yes
disable-dnssec-lame-check: no
module-config: "validator iterator"
root-key-sentinel: yes
trust-anchor-file: "/etc/unbound/trusted-key.key"
val-clean-additional: yes
key-cache-size: 128m
key-cache-slabs: 8
tls-service-key: "/etc/unbound/unbound_server.key"
tls-service-pem: "/etc/unbound/unbound_server.pem"
tls-port: 853
tls-ciphers: "DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256"
tls-ciphersuites: "TLS_AES_128_GCM_SHA256:TLS_AES_128_CCM_8_SHA256:TLS_AES_128_CCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256"
pad-responses: yes
tls-use-sni: yes
tls-cert-bundle: "/etc/ssl/certs/ca-certificates.crt"
python:
dynlib:
remote-control:
control-enable: yes
control-interface: 127.0.0.1
forward-zone:
name: "quad9.com"
forward-addr: 9.9.9.9@853
forward-addr: 149.112.112.112@853
forward-first: yes
forward-tls-upstream: yes
There seem to be no problems with your config, but it is possible to set the TLS authentication name for the forward-addr and you have not set it. This is how you set that:
forward-addr: 9.9.9.9@853#dns.quad9.net
forward-addr: 149.112.112.112@853#dns.quad9.net
Other than that the config should work, also for the trust anchor that looks fine. That still gives permission problems? It is listed once, and not as an include and it is inside the chroot. So that looks a lot better than before.
Thanks for taking some time :) If I replace tust-anchor with auto-trust-anchor, I get this error in systemctl:
Dec 15 18:56:34 laptop unbound[26580]: [1639590994] unbound[26580:0] fatal error: could not open autotrust file for writing, /trusted-key.key.26580-0-55aed4275330: Permission denied
-rw-r----- 1 root wheel 22023792 15 déc. 00:15 blacklist
drwxr-xr-x 2 root root 4096 4 juin 2021 dev
-rw-r----- 1 root wheel 397620 15 déc. 07:15 google.conf
-rw-r--r-- 1 root wheel 3314 29 nov. 01:36 root.hints
drwxr-xr-x 2 root root 4096 4 juin 2021 run
-rw-rw---- 1 unbound root 738 12 déc. 02:02 trusted-key.key
-rw-r----- 1 root wheel 46808 15 déc. 19:05 unbound.conf
-rw-r----- 1 root wheel 46442 24 nov. 04:03 unbound.conf.save
-rw------- 1 root root 2455 4 juin 2021 unbound_control.key
-rw-r----- 1 root root 1411 4 juin 2021 unbound_control.pem
-rw------- 1 root root 2455 4 juin 2021 unbound_server.key
-rw-r----- 1 root root 1549 4 juin 2021 unbound_server.pem
Regards.
EDIT: I just noticed that with the 'chroot' parameter enabled, I no longer have DNSSEC validation.
unbound-host -C /etc/unbound/unbound.conf -v sigok.verteiltesysteme.net
returns to me:
[1639595853] libunbound[61944:0] error: error opening file /trusted-key.key: No such file or directory
[1639595853] libunbound[61944:0] error: error reading trust-anchor-file: /etc/unbound/trusted-key.key
[1639595853] libunbound[61944:0] error: validator: error in trustanchors config
[1639595853] libunbound[61944:0] error: validator: could not apply configuration settings.
[1639595853] libunbound[61944:0] error: module init for module validator failed
resolve error: initialization failure
No errors if I comment out the 'chroot' line.
If I manually load the file /etc/unbound/trusted-key.key, the rights change to
-rw------- 1 root root 758 15 déc. 20:12 trusted-key.key
So, what are the permissions on the directory itself? It needs access to that to create the temporary file that it tries to write to? You do not list that in your ls. Perhaps that is your problem.
Then the file not found with chroot. That is weird, since the file is inside the directory. That it then does not exist. Did you adjust the chroot line in some way? If you comment out you get the default chroot location, so I the string is edited when it is not commented out? The setting "" makes chroot turn off, by default it is turned on.
Okay wait, you post errors from unbound-host -C, that is using the library call, is not the same as starting unbound. So never mind that.
@wcawijngaards: Do you have any idea why the rights of the /etc/unbound/trusted-key.key
file change when I update it (unbound-anchor)?
Maybe it' s what is blocking with 'auto-trust' too?
I put the full functional rights just in case (without 'chroot' option):
total 22M
drwxr-xr-x 4 root root 4,0K 17 déc. 20:37 .
drwxr-xr-x 69 root root 4,0K 17 déc. 22:37 ..
-rw-r----- 1 root wheel 21M 17 déc. 22:36 blacklist
drwxr-xr-x 2 root root 4,0K 4 juin 2021 dev
-rw-r----- 1 root wheel 389K 17 déc. 00:55 google
-rw-r--r-- 1 root wheel 3,3K 15 déc. 23:29 root.hints
drwxr-xr-x 2 root root 4,0K 4 juin 2021 run
-rw-r--r-- 1 root root 757 17 déc. 20:37 trusted-key.key
-rw-r----- 1 root wheel 46K 16 déc. 01:55 unbound.conf
-rw-r----- 1 root wheel 46K 24 nov. 04:03 unbound.conf.save
-rw------- 1 root root 2,4K 4 juin 2021 unbound_control.key
-rw-r----- 1 root root 1,4K 4 juin 2021 unbound_control.pem
-rw------- 1 root root 2,4K 4 juin 2021 unbound_server.key
-rw-r----- 1 root root 1,6K 4 juin 2021 unbound_server.pem
-rw-r----- 1 root wheel 281 16 déc. 02:12 whitelist
Describe the bug A clear and concise description of what the bug is.
Hi, I'm trying to configure Unbound with
auto-trust-anchor
. I've given the userunbound
the rights, but I get errors after running the command# unbound-anchor -va /etc/trusted-key.key
:Here is my unbound.conf (without comments):
To reproduce Steps to reproduce the behavior:
Expected behavior A clear and concise description of what you expected to happen.
System:
unbound -V
output:Additional information Add any other information that you may have gathered about the issue here.