MARWAN docs NOC knowledge base
DocsDNS

Install Unbound on Rocky Linux 9

Install and configure the Unbound validating, recursive and caching DNS resolver on Rocky Linux 9.

Updated Sami

Intro#

Unbound is a validating, recursive, and caching DNS resolver from NLnet Labs. It runs on FreeBSD, OpenBSD, NetBSD by default and is available for Linux, macOS, and Windows. Unbound is written in C and is open-sourced under the BSD license.

We assume you have a frechly installed Rocky Linux 9 with static ip addresses configured. We'll use 2001:db8::53 and 192.0.0.53 as examples. Update and reboot the system:

yum -y upgrade
reboot 

Installation and configuration#

Install EL shipped unbound:

dnf install unbound

Allow the DNS service through firewalld:

firewall-cmd --permanent --add-service=dns
firewall-cmd --reload

Unbound configuration: the configuration file is rather overloaded wich makes unbound highly costumizable. To make it simple, let's override the initial file and only set the most important parts.

cp /etc/unbound/unbound.conf /etc/unbound/unbound.conf.og
> /etc/unbound/unbound.conf
vi /etc/unbound/unbound.conf
/etc/unbound/unbound.conf
server:
	num-threads: 16
	interface: ::1
	interface: 127.0.0.1
	interface: 196.200.160.162
	interface: 2001:4310:f1:d::162

	access-control: 127.0.0.1 allow
	access-control: ::1 allow
	# Adjust to your ipv6 network(s)
	access-control: 2001:db8::/48 allow
	# adjust to your ipv4 network(s)
	access-control: 192.0.2.0/24 allow
	access-control: 192.168.0.0/16 allow

	chroot: ""
	username: "unbound"
	directory: "/etc/unbound"
	pidfile: "/var/run/unbound/unbound.pid"

Finally enable and start Unbound DNS resolver server:

systemctl enable --now unbound

This configuration works for small deployments. For other scenarios, you're better off reading all configuration options.