# The server clause sets the main parameters.
server:
	# verbosity number, 0 is least verbose. 1 is default.
	verbosity: 0

	# print statistics to the log (for every thread) every N seconds.
	# Set to "" or 0 to disable. Default is disabled.
	statistics-interval: 0

	# enable shm for stats, default no.  if you enable also enable
	# statistics-interval, every time it also writes stats to the
	# shared memory segment keyed with shm-key.
	shm-enable: no

	# shm for stats uses this key, and key+1 for the shared mem segment.
	# shm-key: 11777

	# enable cumulative statistics, without clearing them after printing.
	statistics-cumulative: no

	# enable extended statistics (query types, answer codes, status)
	# printed from unbound-control. default off, because of speed.
	extended-statistics: no

	# number of threads to create. 1 disables threading.
	# num-threads: 1

	# specify the interfaces to answer queries from by ip-address.
	# The default is to listen to localhost (127.0.0.1 and ::1).
	# specify 0.0.0.0 and ::0 to bind to all available interfaces.
	# specify every interface[@port] on a new 'interface:' labelled line.
	# The listen interfaces are not changed on reload, only on restart.
	interface: 127.0.0.1
	interface: ::1

	# port to answer queries from
	port: 53

	# Specify a netblock to use remainder 64 bits as random bits for
	# upstream queries.  Uses freebind option (Linux).
	# outgoing-interface: 2001:DB8::/64
	# Also (Linux:) ip -6 addr add 2001:db8::/64 dev lo
	# And: ip -6 route add local 2001:db8::/64 dev lo
	# And set prefer-ip6: yes to use the ip6 randomness from a netblock.
	# Set this to yes to prefer ipv6 upstream servers over ipv4.
	prefer-ip6: yes

	# Prefer ipv4 upstream servers, even if ipv6 is available.
	prefer-ip4: no

	# number of outgoing simultaneous tcp buffers to hold per thread.
	# outgoing-num-tcp: 10

	# number of incoming simultaneous tcp buffers to hold per thread.
	# incoming-num-tcp: 10

	# buffer size for UDP port 53 incoming (SO_RCVBUF socket option).
	# 0 is system default.  Use 4m to catch query spikes for busy servers.
	# so-rcvbuf: 0

	# buffer size for UDP port 53 outgoing (SO_SNDBUF socket option).
	# 0 is system default.  Use 4m to handle spikes on very busy servers.
	# so-sndbuf: 0

	# use SO_REUSEPORT to distribute queries over threads.
	# at extreme load it could be better to turn it off to distribute even.
	so-reuseport: yes

	# msec to wait before close of port on timeout UDP. 0 disables.
	# delay-close: 0

	# perform connect for UDP sockets to mitigate ICMP side channel.
	udp-connect: yes

	# The number of retries when a non-positive response is received.
	# outbound-msg-retry: 5

	# msec for waiting for an unknown server to reply.  Increase if you
	# are behind a slow satellite link, to eg. 1128.
	unknown-server-time-limit: 376

	# the time to live (TTL) value lower bound, in seconds. Default 0.
	# If more than an hour could easily give trouble due to stale data.
	# cache-min-ttl: 300

	# the time to live (TTL) value cap for RRsets and messages in the
	# cache. Items are not cached for longer. In seconds.
	cache-max-ttl: 86400

	# Enable IPv4, "yes" or "no".
	do-ip4: yes

	# Enable IPv6, "yes" or "no".
	do-ip6: yes

	# Enable UDP, "yes" or "no".
	do-udp: yes

	# Enable TCP, "yes" or "no".
	do-tcp: yes

	# Use systemd socket activation for UDP, TCP, and control sockets.
	use-systemd: no

	# Detach from the terminal, run in background, "yes" or "no".
	# Set the value to "no" when Unbound runs as systemd service.
	do-daemonize: no

	# control which clients are allowed to make (recursive) queries
	# to this server. Specify classless netblocks with /size and action.
	# By default everything is refused, except for localhost.
	# Choose deny (drop message), refuse (polite error reply),
	# allow (recursive ok), allow_setrd (recursive ok, rd bit is forced on),
	# allow_snoop (recursive and nonrecursive ok)
	# deny_non_local (drop queries unless can be answered from local-data)
	# refuse_non_local (like deny_non_local but polite error reply).
	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
	access-control: ::ffff:127.0.0.1 allow

	# if given, a chroot(2) is done to the given directory.
	# i.e. you can chroot to the working directory, for example,
	# for extra security, but make sure all files are in that directory.
	#
	# If chroot is enabled, you should pass the configfile (from the
	# commandline) as a full path from the original root. After the
	# chroot has been performed the now defunct portion of the config
	# file path is removed to be able to reread the config after a reload.
	#
	# All other file paths (working dir, logfile, roothints, and
	# key files) can be specified in several ways:
	# 	o as an absolute path relative to the new root.
	# 	o as a relative path to the working directory.
	# 	o as an absolute path relative to the original root.
	# In the last case the path is adjusted to remove the unused portion.
	#
	# The pid file can be absolute and outside of the chroot, it is
	# written just prior to performing the chroot and dropping permissions.
	#
	# Additionally, Unbound may need to access /dev/urandom (for entropy).
	# How to do this is specific to your OS.
	#
	# If you give "" no chroot is performed. The path must not end in a /.
	chroot: "/etc/unbound"

	# if given, user privileges are dropped (after binding port),
	# and the given username is assumed. Default is user "unbound".
	# If you give "" no privileges are dropped.
	username: "unbound"

	# the working directory. The relative files in this config are
	# relative to this directory. If you give "" the working directory
	# is not changed.
	# If you give a server: directory: dir before include: file statements
	# then those includes can be relative to the working directory.
	directory: "/etc/unbound"

	# the log file, "" means log to stderr.
	# Use of this option sets use-syslog to "no".
	logfile: "/dev/null"

	# Log to syslog(3) if yes. The log facility LOG_DAEMON is used to
	# log to. If yes, it overrides the logfile.
	# use-syslog: yes

	# Log identity to report. if empty, defaults to the name of argv[0]
	# (usually "unbound").
	# log-identity: ""

	# print UTC timestamp in ascii to logfile, default is epoch in seconds.
	log-time-ascii: no

	# print one line with time, IP, name, type, class for every query.
	log-queries: no

	# print one line per reply, with time, IP, name, type, class, rcode,
	# timetoresolve, fromcache and responsesize.
	log-replies: no

	# log with tag 'query' and 'reply' instead of 'info' for
	# filtering log-queries and log-replies from the log.
	log-tag-queryreply: no

	# log the local-zone actions, like local-zone type inform is enabled
	# also for the other local zone types.
	log-local-actions: no

	# print log lines that say why queries return SERVFAIL to clients.
	log-servfail: no

	# file to read root hints from.
	# get one from https://www.internic.net/domain/named.cache
	# or from dns-root-hints package in Alpine Linux
	root-hints: "var/named.root"

	# enable to not answer id.server and hostname.bind queries.
	hide-identity: yes

	# Set the identity to report. If set to "", the default, then the
	# hostname of the server is returned.
	identity: "DNS"

	# enable to not answer version.server and version.bind queries.
	hide-version: yes

	# enable to not answer trustanchor.unbound queries.
	hide-trustanchor: yes

	# if enabled the HTTP header User-Agent is not set. Use with
	# caution as some webserver configurations may reject HTTP
	# requests lacking this header.  If needed, it is better to
	# explicitly set the http-user-agent below.
	hide-http-user-agent: yes

	# Set the HTTP User-Agent header for outgoing HTTP requests. If
	# set to "", the default, then the package name and version are
	# used.
	http-user-agent: "DNS"

	# Harden against very small EDNS buffer sizes.
	harden-short-bufsize: yes

	# Harden against unseemly large queries.
	harden-large-queries: yes

	# Harden against out of zone rrsets, to avoid spoofing attempts.
	harden-glue: yes

	# Harden against receiving dnssec-stripped data. If you turn it
	# off, failing to validate dnskey data for a trustanchor will
	# trigger insecure mode for that zone (like without a trustanchor).
	# Default on, which insists on dnssec data for trust-anchored zones.
	harden-dnssec-stripped: yes

	# Harden against queries that fall under dnssec-signed nxdomain names.
	harden-below-nxdomain: yes

	# Harden the referral path by performing additional queries for
	# infrastructure data.  Validates the replies (if possible).
	# Default off, because the lookups burden the server.  Experimental
	# implementation of draft-wijngaards-dnsext-resolver-side-mitigation.
	harden-referral-path: no

	# Harden against algorithm downgrade when multiple algorithms are
	# advertised in the DS record.  If no, allows the weakest algorithm
	# to validate the zone.
	harden-algo-downgrade: yes

	# Sent minimum amount of information to upstream servers to enhance
	# privacy. Only sent minimum required labels of the QNAME and set QTYPE
	# to A when possible.
	qname-minimisation: yes

	# QNAME minimisation in strict mode. Do not fall-back to sending full
	# QNAME to potentially broken nameservers. A lot of domains will not be
	# resolvable when this option in enabled.
	# This option only has effect when qname-minimisation is enabled.
	qname-minimisation-strict: no

	# Aggressive NSEC uses the DNSSEC NSEC chain to synthesize NXDOMAIN
	# and other denials, using information from previous NXDOMAINs answers.
	aggressive-nsec: yes

	# Use 0x20-encoded random bits in the query to foil spoof attempts.
	# This feature is an experimental implementation of draft dns-0x20.
	use-caps-for-id: no

	# Enforce privacy of these addresses. Strips them away from answers.
	# It may cause DNSSEC validation to additionally mark it as bogus.
	# Protects against 'DNS Rebinding' (uses browser as network proxy).
	# Only 'private-domain' and 'local-data' names are allowed to have
	# these private addresses. No default.
	private-address: 10.0.0.0/8
	private-address: 172.16.0.0/12
	private-address: 192.168.0.0/16
	private-address: 169.254.0.0/16
	private-address: fd00::/8
	private-address: fe80::/10
	private-address: ::ffff:0:0/96

	# If nonzero, unwanted replies are not only reported in statistics,
	# but also a running total is kept per thread. If it reaches the
	# threshold, a warning is printed and a defensive action is taken,
	# the cache is cleared to flush potential poison out of it.
	# A suggested value is 10000000, the default is 0 (turned off).
	unwanted-reply-threshold: 10000000

	# if yes, localhost is added to the do-not-query-address entries,
	# both IP6 ::1 and IP4 127.0.0.1/8. If no, then localhost can be
	# used to send queries to. Default is yes.
	do-not-query-localhost: yes

	# if yes, message cache elements are prefetched before they expire
	# to keep the cache up to date. Default is no. Turning it on
	# gives about 10 percent more traffic and load on the machine, but
	# popular items do not expire from the cache.
	prefetch: yes

	# if yes, fetch the DNSKEYs earlier in the validation process,
	# when a DS record is encountered. This lowers the latency of
	# requests. It does use a little more CPU.  Also if the cache is
	# set to 0, it is no use. Default is no.
	prefetch-key: yes

	# deny queries of type ANY with an empty response.
	deny-any: yes

	# if yes, Unbound rotates RRSet order in response.
	rrset-roundrobin: yes

	# if yes, Unbound doesn't insert authority/additional sections
	# into response messages when those sections are not required.
	minimal-responses: yes

	# File with trusted keys, kept uptodate using RFC5011 probes,
	# initial file like trust-anchor-file, then it stores metadata.
	# Use several entries, one per domain name, to track multiple zones.
	#
	# If you want to perform DNSSEC validation, run unbound-anchor before
	# you start Unbound (i.e. in the system boot scripts).
	# And then enable the auto-trust-anchor-file config item.
	# Please note usage of unbound-anchor root anchor is at your own risk
	# and under the terms of our LICENSE (see that file in the source).
	auto-trust-anchor-file: "var/trusted-key.key"

	# Should additional section of secure message also be kept clean of
	# unsecure data. Useful to shield the users of this validator from
	# potential bogus data in the additional section. All unsigned data
	# in the additional section is removed from secure messages.
	val-clean-additional: yes

	# Serve expired responses from cache, with serve-expired-reply-ttl in
	# the response, and then attempt to fetch the data afresh.
	serve-expired: yes
	#
	# Limit serving of expired responses to configured seconds after
	# expiration. 0 disables the limit.
	serve-expired-ttl: 172800
	#
	# Set the TTL of expired records to the serve-expired-ttl value after a
	# failed attempt to retrieve the record from upstream. This makes sure
	# that the expired records will be served as long as there are queries
	# for it.
	serve-expired-ttl-reset: yes
	#
	# TTL value to use when replying with expired data.
	# serve-expired-reply-ttl: 30
	#
	# Time in milliseconds before replying to the client with expired data.
	# This essentially enables the serve-stale behavior as specified in
	# RFC 8767 that first tries to resolve before
	# immediately responding with expired data.  0 disables this behavior.
	# A recommended value is 1800.
	# serve-expired-client-timeout: 0

	# Certificates used to authenticate connections made upstream.
	tls-cert-bundle: "/etc/ssl/certs/ca-certificates.crt"

	# ratelimit for uncached, new queries, this limits recursion effort.
	# ratelimiting is experimental, and may help against randomqueryflood.
	# if 0(default) it is disabled, otherwise state qps allowed per zone.
	ratelimit: 1000


# Remote control config section.
remote-control:
	# Enable remote control with unbound-control(8) here.
	# set up the keys and certificates with unbound-control-setup.
	control-enable: no

# Forward zones
# Create entries like below, to make all queries for 'example.com' and
# 'example.org' go to the given list of servers. These servers have to handle
# recursion to other nameservers. List zero or more nameservers by hostname
# or by ipaddress. Use an entry with name "." to forward all queries.
# If you enable forward-first, it attempts without the forward if it fails.
# forward-zone:
# 	name: "example.com"
# 	forward-addr: 192.0.2.68
# 	forward-addr: 192.0.2.73@5355  # forward to port 5355.
# 	forward-first: no
# 	forward-tcp-upstream: no
# 	forward-tls-upstream: no
#	forward-no-cache: no
# forward-zone:
# 	name: "example.org"
# 	forward-host: fwd.example.com
forward-zone:
	name: "."
	forward-tls-upstream: yes
	forward-no-cache: no
{% for item in unbound_upstream_nameservers %}
	forward-addr: {{ item }}
{% endfor %}
