This allows you to run a Stubby for better DNS over TLS support than Unbound provides without losing the performance benefits of having a local caching DNS resolver.
According to the Stubby documentation:
Unbound can be configured as a local forwarder using DNS-over-TLS to forward queries. However at the moment Unbound does not have all the TCP/TLC features that Stubby has for example, it cannot support 'Strict' mode, it cannot pad queries to hide query size and it opens a separate connection for every DNS query (Stubby will re-use connections)
However, Unbound is a more mature and stable daemon and may be more reliable today.
To achieve this, this setup uses two containers, one running Stubby and another running Unbound. Unbound exposes DNS over port 53 and forwards requests not in its cache to the Stubby container on port 8053 (not publically exposed). Stubby then performs DNS resolution over TLS. By default, this is configured to use Cloudflare DNS.
sudo docker build -t mvance/stubby:latest .
sudo docker build -t mvance/unbound:1.13.1-stubby .
Run these containers with the following command:
docker-compose up -d
Next, point your DNS to the IP of your Docker host running the Unbound container.
While Unbound is not a full authoritative name server, it supports resolving custom entries on a small, private LAN. In other words, you can use Unbound to resolve fake names such as your-computer.local within your LAN.
To support such custom entries using this image, you need to update the provided a-records.conf file. This conf file is where you will define your custom entries for forward and reverse resolution.
The a-records.conf
file should use the following format:
# A Record
#local-data: "somecomputer.local. A 192.168.1.1"
local-data: “laptop.local. A 192.168.1.2”
# PTR Record
#local-data-ptr: "192.168.1.1 somecomputer.local."
local-data-ptr: "192.168.1.2 laptop.local."
Instead of using this image's default Unbound configuration, you may supply your own unbound.conf. See my unbound-docker README for further details. Note, you will likely want to apply the concepts from those directions via docker-compose.yml.
If you have any problems with or questions about this image, please contact me through a GitHub issue.
You are invited to contribute new features, fixes, or updates, large or small. I imagine the upstream projects would be equally pleased to receive your contributions.
Please familiarize yourself with the repository's README.md
file before attempting a pull request.
Before you start to code, I recommend discussing your plans through a GitHub issue, especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.
These deserve credit for making this all possible.
- Docker
- DNSCrypt server Docker image
- Docker
- Filippo Valsorda's Gist
- Franksn's Reddit post
- OpenSSL
- Unbound
Unless otherwise specified, all code is released under the MIT License (MIT). See the repository's LICENSE
file for details.
- DNSCrypt server Docker image: ISC License
- Docker: Apache 2.0
- OpenSSL: Apache-style license
- Stubby: BSD-3-Clause
- Unbound: BSD License