Difference between revisions of "Setting up unbound DNS server"

From Alpine Linux
Jump to: navigation, search
m (root-hints)
Line 71: Line 71:
root-hints: "/etc/unbound/root.hints"
root-hints: "/etc/unbound/root.hints"
Restart unbound to ensure the changes take effect.
Restart unbound to ensure the changes take effect.  You may wish to setup a [[FAQ#My cron jobs don.27t run.3F|cron job]] to update the root hints file occasionally.
= Set auto-start, start and test the daemon =
= Set auto-start, start and test the daemon =

Revision as of 11:33, 27 January 2014

Unbound is a validating, recursive, and caching DNS resolver that supports DNSSEC.


Install the unbound package:

apk add unbound


The following configuration is an example of a caching name server (in a production server, it's recommended to adjust the access-control parameter to limit access to your network). The forward-zone(s) section will forward all DNS queries to the specified servers. Don't forget to change the 'interface' parameter to one of your local interfaces (or to listen on all local IPv4 interfaces). The following is a minimal example with many options commented out.


        verbosity: 1
## Specify the interface address to listen on:
## To listen on all interfaces use:
#       interface:
        do-ip4: yes
        do-ip6: no
        do-udp: yes
        do-tcp: yes
        do-daemonize: yes
        access-control: allow
## Other access control examples
#access-control: action
## 'action' should be replaced by any one of:
#deny (drop message)
#refuse (sends  a  DNS  rcode REFUSED error message back)
#allow (recursive ok)
#allow_snoop (recursive and nonrecursive ok).
## Minimum lifetime of cache entries in seconds.  Default is 0.
#cache-min-ttl: 60
## Maximum lifetime of cached entries. Default is 86400 seconds (1  day).
#cache-max-ttl: 172800
## enable to not answer id.server and hostname.bind queries. 
        hide-identity: yes
## enable to not answer version.server and version.bind queries. 
        hide-version: yes
## default is to use syslog, which will log to /var/log/messages.
use-syslog: yes
## to log elsewhere, set 'use-syslog' to 'no' and set the log file location below:
#logfile: /var/log/unbound
        control-enable: no
## Stub zones are like forward zones (see below) but must only contain authority server (no recursive servers)
#        name: "my.test.com"
#		 stub-addr:
#		 stub-addr:
## Note for forward zones, the destination servers must be able to handle recursion to other DNS server
## Forward all *.example.com queries to the server at
#        name: "example.com"
#        forward-addr:
## Forward all other queries to the Verizon DNS servers
        name: "."
## Level3 Verizon


Instead of forwarding queries to a public DNS server, you may prefer to query the root DNS servers. To do this, comment out the forwarding entries in the config. Then, grab the latest root hints file using wget:

wget http://www.internic.net/domain/named.cache -O /etc/unbound/root.hints

And finally point unbound to the root hints file by adding the following line to the server section of the unbound config file:

root-hints: "/etc/unbound/root.hints"

Restart unbound to ensure the changes take effect. You may wish to setup a cron job to update the root hints file occasionally.

Set auto-start, start and test the daemon

Check the configuration for errors:


and if no errors are reported, set to auto-start then start unbound:

rc-update add unbound rc-service unbound start

Test, for example:

dig nl.alpinelinux.org @


nslookup www.google.cz @

or use drill:

drill www.bbc.co.uk @

Further information

unbound.conf man page here or here

unbound optimization guide

excellent unbound tutorial at calomel.org

General information via the Wikipedia pages on DNS, record types, zones, name servers and DNSsec