This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
computing:unbounddns [2025/05/04 05:27] – 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 / |
+ | sudo nano / | ||
| | ||
In that file, enter something like the following, adjusting as necessary for your use-case. | 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 ''/ | ||
- | | + | |
- | logfile: "/ | + | |
- | | + | |
- | use-syslog: yes | + | |
- | directory: "/ | + | |
- | username: unbound | + | |
- | tls-cert-bundle: | + | |
- | | + | |
- | interface: 0.0.0.0 | + | |
- | interface: ::0 | + | |
- | port: 5335 | + | |
- | do-ip4: yes | + | |
- | do-udp: yes | + | |
- | do-tcp: yes | + | |
- | module-config: | + | |
- | do-ip6: yes | + | |
- | prefer-ip6: no | + | |
- | harden-glue: | + | |
- | harden-dnssec-stripped: | + | |
- | use-caps-for-id: | + | |
- | edns-buffer-size: | + | |
- | prefetch: yes | + | |
- | num-threads: | + | |
- | msg-cache-slabs: | + | |
- | rrset-cache-slabs: | + | |
- | infra-cache-slabs: | + | |
- | key-cache-slabs: | + | |
- | rrset-cache-size: | + | |
- | msg-cache-size: | + | |
- | outgoing-range: | + | |
- | num-queries-per-thread: | + | |
- | infra-cache-numhosts: | + | |
- | #so-rcvbuf: 1m | + | |
- | #so-sndbuf: 2m | + | |
- | so-reuseport: | + | |
- | private-address: | + | |
- | private-address: | + | |
- | private-address: | + | |
- | private-address: | + | |
- | private-address: | + | |
- | private-address: | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | access-control: | + | |
- | access-control: | + | |
- | access-control: | + | |
- | access-control: | + | |
- | aggressive-nsec: | + | |
- | hide-identity: | + | |
- | hide-version: | + | |
- | cache-max-ttl: | + | |
- | cache-min-ttl: | + | |
| | ||
In my case, I prefer traditional rotated logs with rsyslog, so I do the following: | In my case, I prefer traditional rotated logs with rsyslog, so I do the following: | ||
Line 108: | Line 120: | ||
sudo chown unbound / | sudo chown unbound / | ||
| | ||
- | Enforce edns settings specified in config: | + | Enforce edns settings specified in config |
nano / | nano / | ||
< | < | ||
- | The last step is configuring the unbound server in the pihole GUI. Alternately, | + | The last step is configuring the unbound server in the pihole GUI. Go to DNS > Custom and then add '' |
- | server: | + | {{ :computing:screenshot_from_2025-09-20_12-30-26.png?400 |}} |
- | interface: 127.0.0.1 | + | {{ :computing:screenshot_from_2025-09-20_12-28-46.png?400 |}} |
- | cache-max-ttl: 14400 | + | {{ :computing:screenshot_from_2025-09-20_12-23-05.png?400 |}} |
- | cache-min-ttl: 1200 | + | |
- | | + | |
- | msg-cache-slabs: 8 | + | |
- | rrset-cache-slabs: 8 | + | |
- | infra-cache-slabs: 8 | + | |
- | | + | |
- | rrset-cache-size: 256m | + | |
- | msg-cache-size: 128m | + | |
- | #prefetch: yes | + | |
- | harden-dnssec-stripped: yes | + | |
- | use-syslog: yes | + | |
- | aggressive-nsec: | + | |
- | hide-identity: | + | |
- | hide-version: | + | |
- | use-caps-for-id: | + | |
- | do-tcp: yes | + | |
- | do-udp: yes | + | |
- | Then, just 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 ''/ |
- | include-toplevel: | ||
server: | server: | ||
# Bind to localhost only | # Bind to localhost only | ||
Line 149: | Line 143: | ||
access-control: | access-control: | ||
access-control: | access-control: | ||
- | access-control: | + | access-control: |
# Optimize for 8 cores | # Optimize for 8 cores | ||
num-threads: | num-threads: | ||
Line 203: | Line 197: | ||
# Disable subnetcache | # Disable subnetcache | ||
module-config: | module-config: | ||
- | | + | |
- | # forward-zone: | + | # forward-zone: |
- | # name: " | + | # name: " |
- | # forward-addr: | + | # forward-addr: |
- | # forward-addr: | + | # forward-addr: |
- | #legacy | + | |
- | #server: | + | |
- | # interface: 127.0.0.1 | + | |
- | # cache-max-ttl: | + | |
- | # cache-min-ttl: | + | |
- | # num-threads: | + | |
- | # msg-cache-slabs: | + | |
- | # rrset-cache-slabs: | + | |
- | # infra-cache-slabs: | + | |
- | # key-cache-slabs: | + | |
- | # rrset-cache-size: | + | |
- | # msg-cache-size: | + | |
- | # #prefetch: yes | + | |
- | # harden-dnssec-stripped: | + | |
- | # use-syslog: yes | + | |
- | # aggressive-nsec: | + | |
- | # hide-identity: | + | |
- | # hide-version: | + | |
- | # use-caps-for-id: | + | |
- | # do-tcp: yes | + | |
- | # do-udp: yes | + | |
- | # do-ip4: yes | + | |
- | # do-ip6: yes | + | |
- | # prefer-ip6: no | + | |
- | + | ||
- | And now, the current lan-based config is: | + | |
- | server: | + | After that, I navigate to '' |
- | # Logging (minimal) | + | |
- | use-syslog: yes | + | |
- | verbosity: 1 | + | |
- | directory: "/etc/unbound" | + | |
- | username: unbound | + | 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. |
- | # 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 | + | |
- | harden-glue: yes | + | |
- | | + | |
- | | + | |
- | aggressive-nsec: yes | + | |
- | | + | |
- | 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 own subnets) | + | |
- | private-address: | + | |
- | private-address: | + | |
- | private-address: | + | |
- | private-address: | + | |
- | private-address: | + | |
- | # Access control for LAN and VPN subnets | + | |
- | access-control: | + | |
- | | + | |
- | | + | |
- | access-control: | + | |
- | --- // | + | --- // |