This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| computing:unbounddns [2024/11/01 03:51] – created oemb1905 | computing:unbounddns [2025/09/20 18:37] (current) – oemb1905 | ||
|---|---|---|---|
| Line 14: | Line 14: | ||
| sudo apt install unbound | sudo apt install unbound | ||
| - | + | sudo nano / | |
| + | sudo nano / | ||
| + | |||
| + | In that file, enter something like the following, adjusting as necessary for your use-case. | ||
| + | |||
| + | server: | ||
| + | # Logging (minimal) | ||
| + | use-syslog: yes | ||
| + | verbosity: 1 | ||
| + | directory: "/ | ||
| + | username: unbound | ||
| + | # Bind to all interfaces, non-standard port | ||
| + | interface: 0.0.0.0 | ||
| + | interface: ::0 | ||
| + | port: 5335 | ||
| + | do-ip4: yes | ||
| + | do-ip6: yes | ||
| + | prefer-ip6: no | ||
| + | do-udp: yes | ||
| + | do-tcp: yes | ||
| + | # Module configuration | ||
| + | module-config: | ||
| + | # Security and DNSSEC | ||
| + | harden-glue: | ||
| + | harden-dnssec-stripped: | ||
| + | use-caps-for-id: | ||
| + | aggressive-nsec: | ||
| + | hide-identity: | ||
| + | hide-version: | ||
| + | qname-minimisation: | ||
| + | harden-large-queries: | ||
| + | # Cache settings | ||
| + | cache-max-ttl: | ||
| + | cache-min-ttl: | ||
| + | rrset-cache-size: | ||
| + | msg-cache-size: | ||
| + | key-cache-size: | ||
| + | neg-cache-size: | ||
| + | # Performance tweaks | ||
| + | num-threads: | ||
| + | msg-cache-slabs: | ||
| + | rrset-cache-slabs: | ||
| + | infra-cache-slabs: | ||
| + | key-cache-slabs: | ||
| + | outgoing-range: | ||
| + | num-queries-per-thread: | ||
| + | infra-cache-numhosts: | ||
| + | prefetch: yes | ||
| + | prefetch-key: | ||
| + | serve-expired: | ||
| + | serve-expired-ttl: | ||
| + | so-reuseport: | ||
| + | edns-buffer-size: | ||
| + | # Block private address ranges (excluding guest subnet) | ||
| + | private-address: | ||
| + | private-address: | ||
| + | private-address: | ||
| + | private-address: | ||
| + | private-address: | ||
| + | # Access control for guest subnet | ||
| + | access-control: | ||
| + | access-control: | ||
| + | access-control: | ||
| + | |||
| + | If using unbound with a pihole, let ''/ | ||
| - | --- //[[webmaster@haacksnetworking.org|oemb1905]] | + | domain domain.com |
| + | search domain.com | ||
| + | nameserver 192.168.1.254 | ||
| + | |||
| + | In my case, I prefer traditional rotated logs with rsyslog, so I do the following: | ||
| + | |||
| + | sudo apt install rsyslog | ||
| + | sudo nano / | ||
| + | <if $programname == ' | ||
| + | <& stop> | ||
| + | nano / | ||
| + | |||
| + | In the log rotate file, enter the following: | ||
| + | |||
| + | / | ||
| + | daily | ||
| + | rotate 7 | ||
| + | missingok | ||
| + | create 0640 root adm | ||
| + | postrotate | ||
| + | / | ||
| + | endscript | ||
| + | } | ||
| + | |||
| + | Additionally, | ||
| + | |||
| + | systemctl disable | ||
| + | sed -Ei 's/^unbound_conf=/# | ||
| + | rm / | ||
| + | |||
| + | To make sure logs are working properly: | ||
| + | |||
| + | nano / | ||
| + | </ | ||
| + | sudo apparmor_parser -r / | ||
| + | sudo service apparmor restart | ||
| + | sudo mkdir -p / | ||
| + | sudo touch / | ||
| + | sudo chown unbound / | ||
| + | |||
| + | Enforce edns settings specified in config (pihole-only installations): | ||
| + | |||
| + | nano / | ||
| + | < | ||
| + | |||
| + | The last step is configuring the unbound server in the pihole GUI. Go to DNS > Custom and then add '' | ||
| + | |||
| + | {{ : | ||
| + | {{ : | ||
| + | {{ : | ||
| + | |||
| + | Okay, that concludes the steps for setting up pihole+unbound within an openWRT environment. However, one might also want to leverage unbound for public-facing machines. For those use-cases, I enter the following config in ''/ | ||
| + | |||
| + | server: | ||
| + | # Bind to localhost only | ||
| + | interface: 127.0.0.1 | ||
| + | interface: ::1 | ||
| + | port: 53 | ||
| + | do-ip4: yes | ||
| + | do-ip6: yes | ||
| + | prefer-ip6: yes | ||
| + | access-control: | ||
| + | access-control: | ||
| + | access-control: | ||
| + | # Optimize for 8 cores | ||
| + | num-threads: | ||
| + | msg-cache-slabs: | ||
| + | rrset-cache-slabs: | ||
| + | infra-cache-slabs: | ||
| + | key-cache-slabs: | ||
| + | # Cache settings for high query volume | ||
| + | cache-max-ttl: | ||
| + | cache-min-ttl: | ||
| + | rrset-cache-size: | ||
| + | msg-cache-size: | ||
| + | key-cache-size: | ||
| + | neg-cache-size: | ||
| + | # Enable prefetch and expired responses | ||
| + | prefetch: yes | ||
| + | prefetch-key: | ||
| + | serve-expired: | ||
| + | serve-expired-ttl: | ||
| + | # DNSSEC validation for DANE | ||
| + | #do-dnssec: yes | ||
| + | harden-dnssec-stripped: | ||
| + | harden-referral-path: | ||
| + | harden-below-nxdomain: | ||
| + | harden-algo-downgrade: | ||
| + | # Performance tweaks | ||
| + | #so-rcvbuf: 4m | ||
| + | #so-sndbuf: 4m | ||
| + | edns-buffer-size: | ||
| + | outgoing-range: | ||
| + | num-queries-per-thread: | ||
| + | jostle-timeout: | ||
| + | # | ||
| + | # Logging (minimal) | ||
| + | verbosity: 1 | ||
| + | log-queries: | ||
| + | log-replies: | ||
| + | use-syslog: yes | ||
| + | # Security and privacy | ||
| + | hide-identity: | ||
| + | hide-version: | ||
| + | use-caps-for-id: | ||
| + | qname-minimisation: | ||
| + | harden-large-queries: | ||
| + | harden-glue: | ||
| + | aggressive-nsec: | ||
| + | # Protocol settings | ||
| + | do-tcp: yes | ||
| + | do-udp: yes | ||
| + | # Enable full recursion - no longer needed, retained for history | ||
| + | # do-not-query-localhost: | ||
| + | # root-hints: "/ | ||
| + | # Disable subnetcache | ||
| + | module-config: | ||
| + | # Forward to upstream resolvers | ||
| + | # forward-zone: | ||
| + | # name: " | ||
| + | # forward-addr: | ||
| + | # forward-addr: | ||
| + | |||
| + | After that, I navigate to ''/ | ||
| + | |||
| + | nameserver ::1 | ||
| + | nameserver 127.0.0.1 | ||
| + | |||
| + | And, as we already discussed, if you are using unbound without a pihole per se, you would simply adapt the lan-side configuration above and tweak where necessary. | ||
| + | |||
| + | --- //[[alerts@haacksnetworking.org|oemb1905]] | ||