Networking Azure

Unbound 1.24 on Ubuntu 26.04 on Azure User Guide

| Product: Unbound 1.24 on Ubuntu 26.04 LTS on Azure

Overview

Unbound is a fast, lean validating, recursive, caching DNS resolver developed by NLnet Labs. It resolves names for the clients it serves by asking the authoritative servers itself, checks the DNSSEC signature chain on every answer, and caches for low latency, all driven by one plain text configuration with no database and no web console.

The cloudimg image installs Unbound 1.24 from the Ubuntu 26.04 LTS archive and configures it as a hardened private resolver that is safe the moment the VM boots. cloudimg's support team is on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours.

Not an open resolver. A resolver that answers anyone on the internet is a well known DNS amplification and reflection vector. Unbound listens on every interface so it is useful inside your virtual network, but its access-control policy allows recursion only from the VM itself, the RFC1918 private ranges, 100.64.0.0/10 and the private IPv6 ranges fd00::/8 and fe80::/10, and refuses every other source with REFUSED. You can add your own trusted networks (Step 9), never 0.0.0.0/0.

DNSSEC validation on. Every recursive answer is checked against the root trust anchor (/var/lib/unbound/root.key, kept current automatically under RFC 5011). A correctly signed answer carries the ad (Authenticated Data) flag; an answer whose signatures fail is refused with SERVFAIL instead of reaching your clients.

No control credential in the image. A resolver has no admin login. Its only management surface is unbound-control, which this image exposes on a root only unix socket (/run/unbound.ctl, control-use-cert: no) rather than a network TLS port, so there is no control key or certificate to leak or rotate.

What is included:

  • Unbound 1.24 (unbound and unbound-anchor from the Ubuntu 26.04 archive), run by systemd as the unprivileged unbound account under its AppArmor profile (unbound.service)
  • Port 53 over UDP and TCP on every interface, with the not an open resolver access-control policy above
  • DNSSEC validation with aggressive NSEC caching and protection against DNSSEC stripping
  • qname-minimisation, prefetching, hidden identity and version, and per IP and per zone rate limiting
  • dig (from bind9-dnsutils) for testing
  • Ubuntu's unattended security upgrades left on

Unbound 1.24.2 running, controlled over its unix socket, listening on port 53

Prerequisites

  • An Azure subscription, an SSH public key, and a virtual network and subnet in the target region
  • Network Security Group rules allowing TCP 22 from your own network for administration, and UDP 53 and TCP 53 from the clients that will query the resolver

Recommended virtual machine size: Standard_B2s (2 vCPU, 4 GB RAM) for a small resolver. Resolvers serving heavy query volumes should use a larger general purpose size.

Step 1 — Deploy from the Azure Marketplace

Search for Unbound 1.24 on Ubuntu 26.04 in the Azure Marketplace, select the cloudimg listing and click Create. In the Networking tab allow UDP 53 and TCP 53 from your client networks and TCP 22 for administration. DNS uses UDP for most queries and falls back to TCP for large answers, so open both.

Step 2 — Deploy from the Azure CLI

RG="dns-prod"; LOCATION="eastus"; VM_NAME="resolver1"
IMAGE_URN="cloudimg1647283583153:unbound-ubuntu-26-04:default:latest"
az group create --name "$RG" --location "$LOCATION"
# Accept the Marketplace terms once per subscription (required before the first CLI deploy)
az vm image terms accept --urn "$IMAGE_URN"
az vm create \
  --resource-group "$RG" --name "$VM_NAME" \
  --image "$IMAGE_URN" \
  --size Standard_B2s \
  --admin-username azureuser \
  --ssh-key-values ~/.ssh/id_rsa.pub \
  --public-ip-sku Standard
# Allow DNS from your clients (UDP and TCP 53) and SSH; narrow the sources to your own networks
az vm open-port --resource-group "$RG" --name "$VM_NAME" --port 53 --priority 1001
az vm open-port --resource-group "$RG" --name "$VM_NAME" --port 22 --priority 1002

Step 3 — Connect and read the first-boot details

On first boot unbound-firstboot.service confirms DNSSEC validation and the not an open resolver policy are in place, checks the configuration, makes sure Unbound is running and controllable over its unix socket, and writes this VM's resolver details to a root only file. It finishes within a minute of boot. Connect as the admin user you chose at deploy:

ssh azureuser@<vm-public-ip>

Then read the details:

sudo cat /root/unbound-credentials.txt

Expected output (<UNBOUND_HOST> is this VM's address):

# Unbound — validating, recursive, caching DNS resolver — first-boot details.
# These endpoint details are unique to this VM.
#
unbound.host=<UNBOUND_HOST>
unbound.dns.udp=<UNBOUND_HOST>:53
unbound.dns.tcp=<UNBOUND_HOST>:53
unbound.control.socket=/run/unbound.ctl
unbound.dnssec=validated (AD flag set on signed name)
...

The file contains no secret: there is no password or control key on this VM to hand out.

Step 4 — Confirm the resolver is running

unbound.service should be active, and unbound-control status should report the server running with the validator module (DNSSEC) loaded. control(namedpipe) is how Unbound names its unix socket control channel. Unbound listens on port 53 over UDP and TCP:

systemctl is-active unbound.service
unbound -V | head -1
sudo unbound-control status
sudo ss -ulnpH 'sport = :53'
sudo ss -tlnpH 'sport = :53'

Expected output (the pid and uptime differ):

active
Version 1.24.2
version: 1.24.2
verbosity: 1
threads: 1
modules: 2 [ validator iterator ]
uptime: 87 seconds
options: reuseport control(namedpipe)
unbound (pid 2566) is running...
UNCONN 0      0      0.0.0.0:53 0.0.0.0:* users:(("unbound",pid=2566,fd=3))
UNCONN 0      0         [::]:53    [::]:* users:(("unbound",pid=2566,fd=5))
LISTEN 0      256    0.0.0.0:53 0.0.0.0:* users:(("unbound",pid=2566,fd=4))
LISTEN 0      256       [::]:53    [::]:* users:(("unbound",pid=2566,fd=6))

Step 5 — Resolve a name with DNSSEC validation

Query a DNSSEC signed name against the loopback address. The ad flag in the header shows the answer was validated against the root trust anchor, and the RRSIG record is the signature it was checked with:

dig @127.0.0.1 +dnssec +noall +comments +answer cloudflare.com A

Expected output (addresses, TTLs and signatures change):

;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51679
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags: do; udp: 1232
;; ANSWER SECTION:
cloudflare.com.     262 IN  A   104.16.132.229
cloudflare.com.     262 IN  A   104.16.133.229
cloudflare.com.     262 IN  RRSIG   A 13 2 300 20261204141116 20261202121116 34505 cloudflare.com. 7C/zgNyK4f6fgDhizhVx0JTbfAKzNlKmZI7s1yhOvY52Uf6h0XsrAmn6 /7lciGRnzo1qBkQD8ULIlQhvLmK8KA==

A DNSSEC signed name resolved with the ad flag set

Step 6 — Confirm DNSSEC refuses bad data

dnssec-failed.org is a public test domain whose signatures are deliberately broken. A validating resolver must refuse it with SERVFAIL and no answer. unbound-checkconf checks the whole configuration:

dig @127.0.0.1 +noall +comments dnssec-failed.org A
sudo unbound-checkconf

Expected output:

;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 5325
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
unbound-checkconf: no errors in /etc/unbound/unbound.conf

A name with broken DNSSEC signatures refused with SERVFAIL, and the configuration checked

Step 7 — Verify it is not an open resolver

The policy lives in /etc/unbound/unbound.conf.d/00-cloudimg.conf. 0.0.0.0/0 and ::0/0 are refused, and only the VM itself and private ranges are allowed. The control channel is the unix socket with no certificate. The statistics show the queries answered so far and how many came from the cache:

grep -E '^\s*(access-control|control-interface|control-use-cert):' /etc/unbound/unbound.conf.d/00-cloudimg.conf
sudo unbound-control stats_noreset | grep -E '^total.num.(queries|cachehits|cachemiss)='

Expected output (the counts grow with use):

    access-control: 0.0.0.0/0 refuse
    access-control: ::0/0 refuse
    access-control: 127.0.0.0/8 allow
    access-control: ::1 allow
    access-control: 10.0.0.0/8 allow
    access-control: 172.16.0.0/12 allow
    access-control: 192.168.0.0/16 allow
    access-control: 100.64.0.0/10 allow
    access-control: fd00::/8 allow
    access-control: fe80::/10 allow
    control-interface: /run/unbound.ctl
    control-use-cert: no
total.num.queries=14
total.num.cachehits=8
total.num.cachemiss=6

The access-control policy and the resolver statistics

Step 8 — Point your clients at the resolver

From a VM in the same virtual network (an allowed private range), query the resolver's private IP address, shown on the VM's Overview page in the Azure portal:

dig @<resolver-private-ip> +dnssec example.com

To make clients use it permanently, set the resolver's private IP as a custom DNS server on the virtual network (Azure portal > your virtual network > DNS servers > Custom), then restart the client VMs so they pick it up, or set it per client in netplan or systemd-resolved. Keep a second resolver if your workloads cannot tolerate DNS downtime during maintenance.

Queries from public addresses are refused by design, so test from inside the network rather than from your own computer.

Step 9 — Widen access-control to your own networks (optional)

To serve additional trusted client networks (for example a peered network or an on premises range over VPN), add an access-control line inside the server: block of /etc/unbound/unbound.conf.d/00-cloudimg.conf:

access-control: 203.0.113.0/24 allow

Replace 203.0.113.0/24 with your own range. Never add access-control: 0.0.0.0/0 allow: that turns the server into an open resolver. Check and apply the change:

sudo unbound-checkconf
sudo unbound-control reload

Step 10 — Manage Unbound with unbound-control

The control channel is a root only unix socket, so unbound-control works locally with sudo and no credential. Common operations:

sudo unbound-control stats_noreset | grep -E '^total.num.queries='
sudo unbound-control dump_cache | head -3

Expected output (the counts and cached records differ):

total.num.queries=9
START_RRSET_CACHE
;rrset 86352 1 0 3 0
f.root-servers.net. 86352   IN  A   192.5.5.241

Other useful commands, which change the running resolver:

sudo unbound-control reload                  # re-read the configuration
sudo unbound-control flush_zone example.com  # drop cached records for a zone
sudo unbound-control flush_bogus             # drop cached DNSSEC failures

Server components

Component Detail
Unbound 1.24.2 from the Ubuntu 26.04 archive, unbound.service, user unbound, AppArmor profile usr.sbin.unbound
Listener 0.0.0.0:53 and [::]:53, UDP and TCP
Control unbound-control on /run/unbound.ctl (root only, no certificate)
DNSSEC anchor /var/lib/unbound/root.key, refreshed by Unbound under RFC 5011
VM's own DNS systemd-resolved with its local stub listener turned off, so the VM resolves through Azure's DNS while Unbound owns port 53
First boot unbound-firstboot.service, sentinel /var/lib/cloudimg/unbound-firstboot.done

Filesystem layout

Path Purpose
/etc/unbound/unbound.conf Ubuntu's main file, which includes unbound.conf.d/
/etc/unbound/unbound.conf.d/00-cloudimg.conf The cloudimg resolver policy: listeners, access-control, DNSSEC, hardening, control socket
/etc/unbound/unbound.conf.d/root-auto-trust-anchor-file.conf Ubuntu's file declaring the root trust anchor
/etc/unbound/unbound.conf.d/remote-control.conf Ubuntu's file enabling the control socket
/etc/systemd/resolved.conf.d/99-cloudimg-unbound.conf Turns off systemd-resolved's stub listener so Unbound can bind port 53
/root/unbound-credentials.txt This VM's resolver details (root only, 0600)

Keeping Unbound updated

On Ubuntu 26.04 the unbound package is in the universe component. Its updates are published to Ubuntu's resolute-security and resolute-updates pockets, and Ubuntu's unattended upgrades install security updates from resolute-security automatically. To see where the installed version comes from:

apt-cache policy unbound | head -7

Expected output (at build time; the version moves forward as updates are published):

unbound:
  Installed: 1.24.2-1ubuntu2.4
  Candidate: 1.24.2-1ubuntu2.4
  Version table:
 *** 1.24.2-1ubuntu2.4 500
        500 http://azure.archive.ubuntu.com/ubuntu resolute-updates/universe amd64v3 Packages
        500 http://azure.archive.ubuntu.com/ubuntu resolute-security/universe amd64v3 Packages

To update by hand, run sudo apt-get update && sudo apt-get install --only-upgrade unbound. Unbound restarts and keeps your configuration.

Troubleshooting

  • Clients get REFUSED. Their source address is not in an allowed range. Add their network (Step 9), or check they reach the resolver's private IP rather than its public one.
  • Clients time out. Check the Network Security Group allows UDP and TCP 53 from the clients, and that unbound.service is active.
  • Every signed name fails with SERVFAIL. Check the VM's clock (timedatectl): DNSSEC signatures have validity windows. Then check outbound UDP and TCP 53 to the internet is not blocked.
  • Unbound will not start after an edit. Run sudo unbound-checkconf and fix the line it names, then sudo systemctl restart unbound.
  • Logs. journalctl -u unbound -e; first boot logs to /var/log/cloudimg-firstboot.log.

Security recommendations

  • Restrict the Network Security Group. Allow UDP and TCP 53 only from the networks that need the resolver, and TCP 22 only from your own network.
  • Keep recursion scoped. Only add networks you trust (Step 9), never 0.0.0.0/0. The access-control policy is a second layer behind the Network Security Group.
  • Leave DNSSEC validation on. It protects your clients from spoofed or tampered answers.
  • Forward only if you must. If policy requires an upstream resolver, add a forward-zone; resolving directly against the authoritative servers is the more private default.
  • Watch the statistics. unbound-control stats_noreset reports queries, cache hits and validation failures for your monitoring.

Support

cloudimg's support team is on hand 24 hours a day by email at support@cloudimg.co.uk, with a guaranteed response within 24 hours, for deployment help and configuration questions.

Unbound is developed by NLnet Labs and is open source software under the BSD 3 Clause licence. This image uses the unmodified Ubuntu package. cloudimg is not affiliated with or endorsed by NLnet Labs; Unbound is used here only to identify the software.