Setting up a local DNS server with Unbound
Cache Configuration
For most home users, the best reason for using a local DNS server is caching DNS entries and speeding up web browsing. Listing 8 shows an example configuration for a simple, yet powerful, DNS cache.
Listing 8
cache_options.conf
# /etc/unbound/unbound.conf.d/cache_options.conf prefetch: yes # Fetch things before they expire from cache. prefetch-key: yes # Fetch DNSSEC keys early in the validation process. cache-min-ttl: 1200 # Seconds it takes for items in cache to die at minimum.
Domain names have an official time to live assigned by the manager of that domain. This time to live is the time that recursive DNS servers are supposed to keep the DNS entries in their caches before deleting them. Imagine that your Unbound server resolved richard-falken.com
, which at the time of this writing has a TTL of 86400 seconds. It would remember the DNS entry for richard-falken.com
for 24 hours.
Some domains have very short TTLs. The cache-min-ttl
directive in the example defines the minimum time a cached DNS entry will be allowed to live in the cache. If Unbound comes across a domain with a TTL shorter than 1200 seconds, the official TTL will be ignored, and 1200 seconds will be used instead. Beware that DNS entries that are conserved in the cache for too long may become stalled and outdated, which could be counterproductive and lead to problems. Use this directive wisely.
prefetch-key
instructs Unbound to fetch DNSSEC keys earlier than usual in the DNSSEC validation process. It saves time at the expense of CPU load.
prefetch
instructs the server to try to resolve cached entries that are about to expire from the cache in order to keep the cache fresh. This option might increase bandwidth consumption by about 10 percent, but response times will be better.
Privacy
Listing 9 has some privacy options. The most important is qname-minimisation
. Enabling this option makes the queries sent by Unbound to other DNS servers more compact and less prone to leak private information.
Listing 9
privacy_options.conf
# /etc/unbound/unbound.conf.d/privacy_options.conf hide-identity: yes # If enabled id.server and hostname.bind queries are refused. hide-version: yes # If enabled version.server and version.bind queries are refused. qname-minimisation: yes # Send minimum amount of information to upstream servers to enhance privacy.
hide-identity
and hide-version
are less relevant in LAN scenarios, since they prevent the DNS server from replying to internal special queries that attempt to obtain information, such as the hostname of the server or the software version.
Query Times
You may want to check the query times for a server provided by your ISP, another open DNS server on the Internet, or any server you configure on your own LAN.
Proper DNS benchmarking is difficult. A quick and dirty way to check the connection latency for a DNS server is using icmp echo
requests with the ping utility:
$ ping -c 4 $address_of_server
The time stat for each reply indicates the time it took to get a "pong" response from the server. The bigger the time, the longer it takes for the server to reply to you when you ask it to.
The dig utility (Figure 3) performs name resolution, and it is very useful for retrieving DNS records and checking query times.
$ dig @$address_of_dns_server example.org
If you are serious about benchmarking a DNS server, you will need heavier tools for the job. Google's namebench [11] is a popular option.
« Previous 1 2 3 4 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
NVIDIA Released Driver for Upcoming NVIDIA 560 GPU for Linux
Not only has NVIDIA released the driver for its upcoming CPU series, it's the first release that defaults to using open-source GPU kernel modules.
-
OpenMandriva Lx 24.07 Released
If you’re into rolling release Linux distributions, OpenMandriva ROME has a new snapshot with a new kernel.
-
Kernel 6.10 Available for General Usage
Linus Torvalds has released the 6.10 kernel and it includes significant performance increases for Intel Core hybrid systems and more.
-
TUXEDO Computers Releases InfinityBook Pro 14 Gen9 Laptop
Sporting either AMD or Intel CPUs, the TUXEDO InfinityBook Pro 14 is an extremely compact, lightweight, sturdy powerhouse.
-
Google Extends Support for Linux Kernels Used for Android
Because the LTS Linux kernel releases are so important to Android, Google has decided to extend the support period beyond that offered by the kernel development team.
-
Linux Mint 22 Stable Delayed
If you're anxious about getting your hands on the stable release of Linux Mint 22, it looks as if you're going to have to wait a bit longer.
-
Nitrux 3.5.1 Available for Install
The latest version of the immutable, systemd-free distribution includes an updated kernel and NVIDIA driver.
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.