
Unbound is a validating, recursive, and caching DNS resolver. Unlike some other DNS servers that rely on heavy web interfaces, Unbound is designed to be lean, fast, and secure. It rigorously validates DNSSEC signatures to ensure the authenticity of the data it serves, making it a preferred choice for privacy-conscious users and enterprise environments.
This article demonstrates how to deploy Unbound DNS Server on Ubuntu 24.04 using Docker Compose.
Before you begin:
DNS servers communicate using port 53. By default, Ubuntu 24.04 runs its own internal DNS service called systemd-resolved on this port. You must disable this internal service so that Unbound can take control of port 53.
Additionally, you need to ensure the server itself can still connect to the internet to download updates, even if Unbound is stopped. To do this, you will configure the server to use a public DNS provider.
Stop the systemd-resolved service.
Disable the service so it does not start again when you reboot.
Remove the existing DNS configuration file.
Create a new DNS configuration file.
Unbound relies on a configuration file to define its behavior, access controls, and security features. You must create the necessary directory structure to store this file.
Create the project directory.
Navigate to the directory.
Create the unbound.conf configuration file.
Add the following configuration content. Replace YOUR_CLIENT_IP with the public IP address of the client device that will query this server. To allow multiple clients, add additional access-control lines.
Save and close the file.
This configuration defines Unbound’s security posture, access rules, and performance behavior:
Listening Interfaces: Unbound listens on all IPv4 and IPv6 interfaces so it can accept DNS queries from allowed clients.
Access Control: Controls who may query your resolver.
YOUR_CLIENT_IP/32 represent individual clients.0.0.0.0/0) is explicitly denied for safety.Security Settings:
hide-identity and hide-version prevent Unbound from revealing software details.use-caps-for-id adds DNS query randomization to prevent spoofing attacks.prefetch refreshes items in cache before expiration.Performance Tuning: Optimized cache sizes, slab counts, and thread counts improve speed and reduce latency on small-to-medium servers.
Remote Control Disabled: Prevents external control commands for increased security.
This section sets up the Unbound deployment using the popular mvance/unbound Docker image.
Create the Docker Compose manifest file.
Add the following contents. Replace UTC with your preferred timezone.
Save and close the file.
This Docker Compose configuration deploys a standalone Unbound server that listens directly on standard DNS ports. Each setting plays a specific function in the deployment:
unbound service
mvance/unbound image.53/tcp and 53/udp to allow standard DNS queries from your allowed clients.unbound.conf file into the container at /opt/unbound/etc/unbound/unbound.conf. The :ro flag ensures the container reads the file as read-only, preventing accidental changes from inside the container.unless-stopped) to ensure high availability after server reboots.Start the service in detached mode.
Check the container status.
Verify that the Unbound server is functioning correctly by querying it directly.
Run this command from your client's terminal. Replace SERVER_IP with your server's public IP address.
You should see a standard DNS response with an A record of vultr.com
You have successfully deployed Unbound DNS Server on Ubuntu 24.04. You now have a high-performance, validating recursive resolver. You can further customize the unbound.conf file to add local zones, blocklists, or advanced caching rules.
0 Comments
Be the first to comment and share your perspective with the community.