Td
Networking Azure

Technitium DNS Server on Ubuntu 24.04 on Azure User Guide

| Product: Technitium DNS Server on Ubuntu 24.04 on Azure

Overview

This image runs the official Technitium DNS Server 15.6.2 release on Ubuntu 24.04 LTS. Technitium DNS Server is an open source DNS server that hosts your own zones (authoritative DNS) and resolves names for your networks (recursive DNS), managed from a web console or its HTTP API. It supports primary, secondary, stub and conditional forwarder zones, DNSSEC signing and validation, DNS over TLS, HTTPS and QUIC, block lists, query logs and a statistics dashboard.

The server runs on the ASP.NET Core 10 runtime from Ubuntu's own archive, so Ubuntu's unattended security upgrades patch the runtime along with the rest of the system.

The server sets itself up on the first boot of every virtual machine. The administrator password and the web console's TLS certificate are created on your virtual machine and never shared with another one, and the upstream default password (admin) never works. The password is written to /root/technitium-dns-credentials.txt, readable by root only.

The image is set up as follows:

  • The web console and HTTP API are served over HTTPS on port 53443. Port 5380 only redirects to HTTPS.
  • Recursion is answered for private networks only, so the server is never an open resolver on the internet. The zones you host are answered for everyone who can reach port 53.
  • The DNS server runs as its own unprivileged user, dns-server, with only the right to bind port 53, and it cannot reach the Azure instance metadata endpoint.
  • The virtual machine itself keeps using Azure DNS through systemd-resolved, so it still resolves names while the DNS server is stopped or being reconfigured.
  • Ubuntu's unattended security upgrades are switched on.

The default operating system user is the administrator account you choose when you create the virtual machine (azureuser in the examples below).

Prerequisites

  • A Microsoft Azure subscription in which you can create resource groups, virtual networks and virtual machines
  • An SSH key pair for the administrator account
  • The Azure CLI (az) if you deploy from the command line

The recommended size is Standard_B2s (2 vCPUs, 4 GiB memory). It serves a busy office network or many hosted zones comfortably. Choose a larger size for large block lists or very high query rates.

Step 1: Deploy the Virtual Machine

Option A: the Azure Portal

  1. Sign in to the Azure Portal, open Marketplace, search for Technitium DNS Server on Ubuntu 24.04 by cloudimg and select Create.
  2. On Basics choose your subscription, a resource group, a region and a name, and pick Standard_B2s or larger. Under Administrator account choose SSH public key and enter your user name and key.
  3. Under Inbound port rules allow SSH (22). After the virtual machine is created, add rules on its network security group for TCP 53443 (the web console) from your own network, and for port 53 (DNS) as described in steps 6 and 7.
  4. Select Review + create, then Create.

First boot finishes about a minute after the virtual machine shows Running.

Option B: the Azure CLI

Accept the Marketplace terms once per subscription, then create the virtual machine. Replace <your-mgmt-cidr> with the network you connect from, for example 203.0.113.0/24. SSH and the web console are opened to that network only.

az vm image terms accept --urn cloudimg1647283583153:technitium-dns-server:default:latest

RG=technitium-rg
az group create --name $RG --location eastus
az vm create \
  --resource-group $RG \
  --name technitium-01 \
  --image cloudimg1647283583153:technitium-dns-server:default:latest \
  --size Standard_B2s \
  --admin-username azureuser \
  --ssh-key-values ~/.ssh/id_rsa.pub \
  --public-ip-sku Standard \
  --nsg-rule NONE
az network nsg rule create --resource-group $RG --nsg-name technitium-01NSG \
  --name AllowMgmt --priority 1000 --access Allow --protocol Tcp \
  --direction Inbound --source-address-prefixes <your-mgmt-cidr> --destination-port-ranges 22 53443

Step 2: Connect to the Virtual Machine

Find the public IP address, then connect over SSH:

az vm show --resource-group technitium-rg --name technitium-01 --show-details --query publicIps -o tsv
ssh azureuser@<public-ip>

The message of the day shows the console address and where the credentials are:

  Technitium DNS Server 15.6.2 on Ubuntu 24.04 (cloudimg)
  Web console:        https://203.0.113.10:53443/
  Admin credentials:  sudo cat /root/technitium-dns-credentials.txt
  Service:            systemctl status dns
  User guide:         https://www.cloudimg.co.uk/guides/technitium-dns-server-on-ubuntu-24-04-azure/

Check that the server is running and that the console answers:

systemctl is-active dns technitium-dns-firstboot
dotnet --list-runtimes | grep AspNetCore
curl -sk -o /dev/null -w '%{http_code}\n' https://127.0.0.1:53443/
active
active
Microsoft.AspNetCore.App 10.0.15 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
200

Technitium DNS Server service, runtime and web console check on a new VM

Step 3: Read the Administrator Credentials

sudo cat /root/technitium-dns-credentials.txt

The file holds the console address, the administrator user name (admin) and the administrator password created for this virtual machine:

# Technitium DNS Server 15.6.2 - generated on first boot by technitium-dns-firstboot.service.
# Unique to this VM; store it safely.
DNS_CONSOLE_URL=https://203.0.113.10:53443/
technitium.admin.user=admin
technitium.admin.pass=************************

# Sign in to the web console at DNS_CONSOLE_URL as admin, then change the password from the
# admin menu (top right) > Change Password. The console uses a certificate the DNS server generated for this VM,
# so your browser warns until you install your own. Port 5380 only redirects to HTTPS.
# DNS: UDP and TCP port 53. Recursion is allowed for private networks only, so clients on the public internet get
# answers only from the zones you host.
# User guide: https://www.cloudimg.co.uk/guides/technitium-dns-server-on-ubuntu-24-04-azure/

Store the password in a password manager. If Azure did not report a public IP address when the virtual machine first booted (for example, a virtual machine with only a private address), the console address in the file uses the private address instead.

The per VM credentials file and its permissions

Step 4: Sign in to the Web Console

Open https://<public-ip>:53443/ in your browser. The certificate is a self-signed one the server made for this virtual machine on first boot, so the browser warns once; accept it to continue, or install your own certificate (step 9). Sign in as admin with the password from step 3.

The Technitium DNS Server sign-in page

The dashboard shows the queries the server has answered, by type and by result, with the top clients and domains.

The Technitium DNS Server dashboard after signing in

Change the password from the user menu at the top right (Change Password) if you want one of your own, and give every other administrator their own account under Administration, Users.

Step 5: Host Your First Zone

Zones are created under Zones, Add Zone in the console. Everything the console does is also available from the HTTP API, which suits scripts and automation. This signs in to the API (the password goes to curl on its standard input, never on a command line), creates a primary zone, corp.example.internal, with an A record for www, then queries it:

API=https://127.0.0.1:53443/api
TOKEN=$(sudo awk -F= '/^technitium.admin.pass=/{printf "%s", $2}' /root/technitium-dns-credentials.txt \
  | curl -sk "$API/user/login" --data-urlencode user=admin --data-urlencode pass@- | jq -r .token)
curl -sk -H "Authorization: Bearer $TOKEN" "$API/zones/create" -d zone=corp.example.internal -d type=Primary | jq -r .status
curl -sk -H "Authorization: Bearer $TOKEN" "$API/zones/records/add" -d zone=corp.example.internal \
  -d domain=www.corp.example.internal -d type=A -d ttl=3600 -d ipAddress=192.0.2.10 | jq -r .status
dig @127.0.0.1 www.corp.example.internal A +noall +comments +answer | grep -E 'flags|IN'
ok
ok
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
; EDNS: version: 0, flags:; udp: 1232
www.corp.example.internal. 3600 IN  A   192.0.2.10

The aa flag shows the answer is authoritative: it comes from your zone, not from a cache. The zone now shows in the console with its records:

The corp.example.internal zone and its records in the console

The full API reference is at https://github.com/TechnitiumSoftware/DnsServer/blob/master/APIDOCS.md.

Step 6: Resolve Names for Your Virtual Network

The server resolves internet names for clients on private networks (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 and the IPv6 private ranges), and refuses recursion for everyone else. The setting is under Settings, Recursion:

Recursion allowed for private networks only, in the console's settings

Check it from the virtual machine:

dig @127.0.0.1 www.cloudimg.co.uk A +short
dig +tcp @127.0.0.1 corp.example.internal SOA +short
d14bmdyrx9dte8.cloudfront.net.
3.167.88.51
3.167.88.45
3.167.88.108
3.167.88.56
technitium-01. hostadmin.corp.example.internal. 2 900 300 604800 900

DNS queries answered over UDP and TCP from the hosted zone and by recursion

The console's DNS Client tab runs the same queries from your browser against This Server:

The DNS Client resolving a name against this server

To make every virtual machine in your virtual network use this server, allow port 53 from the virtual network in the network security group, then set the server's private address as the virtual network's DNS server. Run this from your workstation; the virtual network's name is the one your virtual machine uses (az vm create names it technitium-01VNET when it makes one):

PRIVATE_IP=$(az vm show --resource-group technitium-rg --name technitium-01 --show-details --query privateIps -o tsv)
az network nsg rule create --resource-group technitium-rg --nsg-name technitium-01NSG \
  --name AllowDnsFromVnet --priority 1010 --access Allow --protocol '*' \
  --direction Inbound --source-address-prefixes VirtualNetwork --destination-port-ranges 53
az network vnet update --resource-group technitium-rg --name technitium-01VNET --dns-servers "$PRIVATE_IP"

Virtual machines pick up the new DNS server when they renew their DHCP lease or restart. For names Azure resolves privately (Azure Private DNS zones, private endpoints), add a conditional forwarder zone in the console that forwards those names to Azure's resolver, 168.63.129.16.

Step 7: Serve Your Zones to the Internet

To answer public queries for a domain you own, create the zone (as in step 5, with your domain's real name), allow port 53 from the internet, and then add NS records at your registrar that point to this server's public address. Recursion stays limited to private networks, so opening port 53 never makes the server an open resolver.

az network nsg rule create --resource-group technitium-rg --nsg-name technitium-01NSG \
  --name AllowDnsFromInternet --priority 1020 --access Allow --protocol '*' \
  --direction Inbound --source-address-prefixes Internet --destination-port-ranges 53

For a public domain, sign the zone from its DNSSEC menu in the console (Sign Zone), and publish the DS record at your registrar.

Step 8: Forwarders and Block Lists

By default the server resolves names itself from the root servers. To send recursive queries to an upstream resolver instead, open Settings, Proxy & Forwarders, and pick a forwarder. To block advertising, tracking or malware domains for your clients, open Settings, Blocking, and add one or more block list URLs; the server downloads them and refreshes them every day.

Step 9: Use Your Own TLS Certificate

The console uses a certificate the server made for this virtual machine. To use your own, convert the certificate and its key to a PKCS #12 (.pfx) file, copy it to /etc/dns/, owned by dns-server, then set its path and password under Settings, Web Service, TLS Certificate File Path. Leave Use A Self Signed TLS Certificate off once your own certificate is in place. The same page sets the ports the console listens on.

Step 10: Back Up and Upgrade

The whole configuration (settings, zones, users, block lists and statistics) lives in /etc/dns. Settings, Backup Settings in the console downloads it as a zip file you can restore on any Technitium DNS Server. From the command line, stop the server, copy the folder, and start it again. Replace <backup-dir> with a folder on another disk or a mounted share:

sudo systemctl stop dns
sudo tar -C / -czf <backup-dir>/technitium-dns-$(date +%F).tar.gz etc/dns
sudo systemctl start dns

Ubuntu's unattended upgrades keep Ubuntu and the ASP.NET Core runtime patched. Technitium DNS Server itself is upgraded by replacing its files in /opt/technitium/dns with a newer portable release from https://technitium.com/dns/, after a backup. The settings in /etc/dns carry over. Replace <version> with the release you want:

curl -fsSLo /tmp/DnsServerPortable.tar.gz https://download.technitium.com/dns/archive/<version>/DnsServerPortable.tar.gz
sudo systemctl stop dns
sudo tar -xzf /tmp/DnsServerPortable.tar.gz -C /opt/technitium/dns
sudo systemctl start dns

Check the new release's notes first: a new major release may need a newer ASP.NET Core runtime.

Server Components

Component Version Notes
Technitium DNS Server 15.6.2 The official portable release, in /opt/technitium/dns, run by dns.service as the dns-server user
ASP.NET Core runtime 10.0.15 Ubuntu's aspnetcore-runtime-10.0 package, patched by unattended upgrades
systemd-resolved Ubuntu 24.04 The virtual machine's own resolver (Azure DNS), with its port 53 stub listener turned off
Ubuntu 24.04 LTS Azure kernel 6.8, unattended security upgrades on

Filesystem Layout

Mount Size What is there
/ 30 GB OS disk (29 GB root partition) Ubuntu, the program in /opt/technitium/dns, settings and zones in /etc/dns, logs in /var/log/technitium/dns
/boot 881 MB Kernels
/boot/efi 105 MB EFI system partition
/mnt Azure temporary disk (size depends on the VM size) Scratch space only: Azure may wipe it on a stop, resize or redeploy. Never keep zones or backups here

Query logs can grow quickly on a busy server. Set how many days of logs to keep under Settings, Logging, or attach a managed data disk for them.

Managing the Service

sudo systemctl status dns --no-pager
sudo systemctl restart dns
sudo journalctl -u dns --no-pager -n 50

Scripts and Log Files

Path What it does
/opt/technitium/dns The Technitium DNS Server program files, owned by root
/etc/dns Settings, zones, users and certificates (owned by dns-server)
/var/log/technitium/dns The server's own logs and query logs, kept as daily files
/root/technitium-dns-credentials.txt The console address and administrator credentials (root only)
/usr/local/sbin/technitium-dns-firstboot.sh First boot: sets the administrator password and the console's certificate, then writes /var/lib/cloudimg/technitium-dns-firstboot.done
/usr/local/lib/cloudimg/technitium-dns-api.sh Bash functions for the HTTP API (tdns_login, tdns_call), used by the image's own checks
/usr/local/sbin/technitium-dns-cred-roundtrip.sh Checks that the password in the credentials file signs in, and a wrong one is refused (run with sudo)
journalctl -u technitium-dns-firstboot The first boot log
journalctl -u dns The service log

On Startup

On the first boot technitium-dns-firstboot.service runs once: it makes the administrator password, starts the DNS server with it so the server creates its configuration and its certificate, proves the new password signs in and the default one does not, then writes the credentials file and records /var/lib/cloudimg/technitium-dns-firstboot.done. The DNS server (dns.service) does not start until that file exists, so it never runs with a default password. On every later boot dns.service starts as a normal systemd service.

Troubleshooting

The credentials file is not there yet. First boot is still running. Wait a minute, then check systemctl status technitium-dns-firstboot --no-pager and journalctl -u technitium-dns-firstboot --no-pager.

The browser cannot reach port 53443. Check that the network security group allows TCP 53443 from your address (step 1), and that systemctl is-active dns reports active.

The browser warns about the certificate. The certificate is self-signed for this virtual machine. Install your own (step 9).

Clients get REFUSED for internet names. Recursion is answered only for private networks. Clients must query the server's private address from inside your virtual network, or from a network connected to it by VPN or peering.

Port 53 is already in use after changes. The image turns off the systemd-resolved stub listener so the DNS server can use port 53. Check sudo ss -lntup | grep ':53 ' and keep DNSStubListener=no in /etc/systemd/resolved.conf.d/90-cloudimg-technitium.conf.

Security Recommendations

The server listens on SSH (22), DNS (53, UDP and TCP), the console over HTTPS (53443) and the redirect port (5380); it runs as dns-server, cannot reach the Azure metadata endpoint, and never writes a core dump:

Listening ports, the service account and the metadata block

  • Open TCP 53443 and SSH only to your own network.
  • Keep recursion limited to private networks unless you have a reason to change it.
  • Give each administrator their own account, and use API tokens (Administration, Sessions, Create Token) for scripts.
  • Install your own certificate for the console.
  • Leave unattended upgrades on, and upgrade Technitium DNS Server when a new release is published.

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 Technitium DNS Server itself, see https://technitium.com/dns/ and the project's repository at https://github.com/TechnitiumSoftware/DnsServer.

Technitium DNS Server is licensed under the GNU General Public License v3. All product and company names are trademarks or registered trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.