Deployment guide

dnsmasq

Overview

This guide shows you how to deploy and configure dnsmasq on Ubuntu 24.04 on Azure with the SecureAnyCloud Azure Marketplace image. dnsmasq is a small, widely deployed network infrastructure daemon. It combines a caching DNS forwarder, a DHCP server and a TFTP boot server in a single lightweight package. It suits local networks, edge sites, labs and container hosts that need name resolution and address assignment without heavyweight services.

The image installs dnsmasq 2.90 from the Ubuntu 24.04 archive and configures it as a secure-by-default caching DNS forwarder. Unattended security upgrades remain enabled on the running VM, so the package keeps receiving patches.

Not an open resolver. An open recursive or forwarding resolver resolves arbitrary names for anyone on the internet. Such a resolver is a well-known DNS amplification and reflection DDoS vector. This image ships with dnsmasq's local-service mode, so the server answers DNS only for hosts whose source address is on a local subnet of this VM. A query that arrives from the public internet is silently dropped, never answered and never reflected. The server therefore cannot be abused as an amplifier.

The forwarder also sets domain-needed and bogus-priv, so unqualified names and private reverse lookups are never sent upstream. It sets no-resolv with an explicit upstream list (1.1.1.1, 9.9.9.9).

DHCP and TFTP are off by default. dnsmasq can also serve DHCP and TFTP. Running a DHCP server on a network you do not own is a rogue DHCP hazard, and an open TFTP root is a data exfiltration vector. This image therefore ships with neither enabled, with no dhcp-range and no enable-tftp. You turn them on deliberately for your own network (see Step 9 and Step 10).

No bootstrap credential. dnsmasq has no login or admin password of any kind. You configure it entirely through files under /etc/dnsmasq.d/. There is nothing to leak, so no shared secret ships in the image.

What you get:

  • dnsmasq 2.90 from the Ubuntu 24.04 archive, run under systemd as the unprivileged dnsmasq user (dnsmasq.service).
  • A secure caching DNS forwarder configuration: local-service (not an open resolver), no-resolv with explicit upstreams, domain-needed, bogus-priv and a response cache.
  • A shipped local example record (ns.dnsmasq.internal resolves to 10.0.0.53), so a DNS round trip works out of the box even before any upstream is reachable.
  • DHCP and TFTP present in the daemon but disabled by default, with a documented opt-in for your own network.
  • The systemd-resolved stub listener disabled, so dnsmasq owns port 53 while the host still resolves names through its own upstreams.
  • An Ubuntu 24.04 LTS base with the latest security patches applied at build time, and unattended security upgrades kept enabled.
  • The Azure Linux Agent for cloud integration and SSH key injection.
  • 24/7 SecureAnyCloud support with a guaranteed 24-hour response SLA.

Prerequisites

You need an active Azure subscription, an SSH public key, and a VNet and subnet in the target region.

You also need a subscription to the dnsmasq listing on Azure Marketplace.

Add network security group rules that allow TCP 22 (admin) and both UDP and TCP 53 (DNS) from the clients that will query the server.

Recommended virtual machine size: Standard_B2s (2 vCPU, 4 GB RAM) is ample for a caching forwarder that serves a local network. Sites with very high query volumes can use Standard_D2s_v5 or larger.

1

Deploy from the Azure Portal

Search for dnsmasq in Azure Marketplace, select the SecureAnyCloud publisher, and choose Create.

Configure the network security group to allow UDP 53 and TCP 53 (DNS) from your client networks, and TCP 22 for administration. DNS uses UDP 53 for most queries and falls back to TCP 53 for large responses, so open both.

2

Deploy from the Azure CLI

RG="dns-prod"; LOCATION="eastus"; VM_NAME="dnsmasq1" IMAGE_URN="sac1647283583153:dnsmasq:default:latest" SSH_KEY="$(cat ~/.ssh/id_rsa.pub)" 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 sac1647283583153:dnsmasq:default:latest
az vm create \
  --resource-group "$RG" --name "$VM_NAME" \
  --image "$IMAGE_URN" \
  --size Standard_B2s \
  --admin-username azureuser \
  --ssh-key-values "$SSH_KEY" \
  --public-ip-sku Standard
# Open the DNS and admin ports on the VM's NSG:
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
3

First boot

On first boot, the image resolves the VM public IP and asserts the secure defaults (local-service on, DHCP and TFTP off). It tests the dnsmasq configuration and starts the service. It proves that the local record answers and that upstream forwarding works. Finally, it writes /root/dnsmasq-credentials.txt.

First boot completes within a minute. SSH in as azureuser and read the details:

sudo cat /root/dnsmasq-credentials.txt
4

Confirm the service is running

dnsmasq.service is active and owns port 53. ss confirms that dnsmasq is the listener on :53 for both UDP and TCP.

systemctl is-active dnsmasq.service
sudo ss -tulnp | grep -E ':53 ' || echo "(dnsmasq is not yet listening on :53)"
5

Test DNS resolution

The image ships one local example record, ns.dnsmasq.internal, so a DNS round trip works immediately without any upstream. Forwarding of external names to the upstream resolvers also works out of the box.

Query the loopback address, or the VM public IP from a client:

dig @127.0.0.1 ns.dnsmasq.internal +short dig @127.0.0.1 example.com +short
6

Review the configuration

The SecureAnyCloud configuration lives in /etc/dnsmasq.d/00-sac.conf. The command dnsmasq --test validates the whole configuration. The version is 2.90 from the Ubuntu archive.

dnsmasq --version | head -1 sudo dnsmasq --test cat /etc/dnsmasq.d/00-sac.conf
7

Verify the responsible defaults

This check covers the key security property. local-service is present, so the server answers only local subnet clients and is not an open resolver. There is no dhcp-range and no enable-tftp, so DHCP and TFTP are off by default.

grep -E '^\s*(local-service|no-resolv|domain-needed|bogus-priv)' /etc/dnsmasq.d/00-sac.conf echo '--- DHCP and TFTP are off by default (the next command returns nothing): ---'
grep -E '^\s*(dhcp-range|enable-tftp)' /etc/dnsmasq.d/00-sac.conf || echo 'confirmed: no dhcp-range and no enable-tftp are set'
8

Point clients at the server

Configure the devices or the router on your local network to use the VM as their DNS server. On a Linux client, set the nameserver to the VM address. Replace <public-ip> with the VM public IP, or with its private IP inside the VNet:

echo "nameserver <public-ip>" | sudo tee /etc/resolv.conf

Because of local-service, dnsmasq answers only clients whose address is on a subnet local to the VM. Keep the server and its clients on the same VNet or a peered network.

9

Enable DHCP for your own subnet (optional)

dnsmasq can hand out DHCP leases on a subnet you control. Enable DHCP only on a network where you are the intended DHCP server.

Add a stanza like the following to /etc/dnsmasq.d/00-sac.conf. Adjust the interface and range to your subnet:

interface=eth0 dhcp-range=192.0.2.50,192.0.2.150,255.255.255.0,12h dhcp-option=option:router,192.0.2.1

Open UDP 67 in the network security group, then restart the service with sudo systemctl restart dnsmasq.

Adding an interface= line also disables local-service. If you enable DHCP, add an explicit except-interface or an address-based restriction. This keeps the DNS forwarder from answering untrusted sources.

10

Enable TFTP and PXE boot (optional)

dnsmasq includes a TFTP server for network boot. To serve a TFTP root, add the following to /etc/dnsmasq.d/00-sac.conf:

enable-tftp tftp-root=/srv/tftp dhcp-boot=pxelinux.0

Create /srv/tftp and place your boot files there. Open UDP 69 in the network security group, and restart with sudo systemctl restart dnsmasq.

Keep the TFTP root read-only, and populate it with only the files you intend to serve.

11

Add local DNS records and custom upstreams (optional)

To add your own local names or change the upstream resolvers, add a file such as /etc/dnsmasq.d/50-local.conf:

# local names answered directly by dnsmasq host-record=app.internal,10.0.0.20 address=/dev.internal/10.0.0.30
# use your own upstream resolvers instead of the defaults server=10.0.0.1

Validate with sudo dnsmasq --test and apply with sudo systemctl reload dnsmasq.

12

Security recommendations

Restrict the network security group. Allow UDP and TCP 53 only from the client networks that need to query the server, and TCP 22 for administration only.

Keep it a local service. The shipped local-service default means the server never answers the public internet. If you add an interface= line for DHCP, add an explicit source restriction again, so the DNS forwarder does not become an open resolver.

Enable DHCP and TFTP only where you own the network. A stray DHCP server or an open TFTP root on someone else's network is a security incident.

Keep the OS and dnsmasq patched. Unattended security upgrades remain enabled on the running VM.

Monitor the leases file. If you enable DHCP, /var/lib/misc/dnsmasq.leases records active leases.

13

Support and licensing

dnsmasq is free software written by Simon Kelley and distributed under the GNU General Public License, version 2 (GPL-2.0). This SecureAnyCloud image bundles the unmodified Ubuntu archive package.

SecureAnyCloud provides the packaging and the secure caching forwarder hardening. It also provides the not-an-open-resolver defaults, the DHCP-and-TFTP-off-by-default posture and the local example record. Support is 24/7, with a guaranteed 24-hour response SLA.

SecureAnyCloud is not affiliated with or endorsed by the dnsmasq project or Simon Kelley. dnsmasq is used here only to identify the software.

Deploy on Azure

Find dnsmasq on Ubuntu 24.04 LTS in Azure Marketplace, published by SecureAnyCloud. Deploy from the Azure Portal or the Azure CLI as shown above.

Need Help?

Email sales@secureanycloud.com for deployment help, configuration questions or licensing inquiries.

Deploy on Azure

Launch dnsmasq 2.90 on Ubuntu 24.04 LTS on Azure, with 24/7 support from SecureAnyCloud.

View this image

Need Help?

Our support team is available 24/7.

sales@secureanycloud.com

Deploy on Azure