Skip to content

About

Self-hosted DNS stack combining AdGuard Home filtering with a private BIND 9 recursive resolver, DNSSEC validation and Docker hardening.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

adguard-bind9

A simple self-hosted DNS stack combining AdGuard Home with a private BIND 9 recursive resolver.

AdGuard handles filtering and client policies. BIND resolves domains directly through the DNS hierarchy, provides caching, and validates DNSSEC — without requiring a public recursive provider such as Google, Cloudflare or Quad9.

Architecture

LAN / VLAN clients
        |
        | TCP + UDP 53
        v
+----------------------+ 
|     AdGuard Home     |
|      172.30.0.4      |
|                      |
| filtering / policies |
+----------+-----------+
           |
           | private Docker network
           v
+----------------------+
|        BIND 9        |
|      172.30.0.3      |
|                      |
| recursion / cache    |
| DNSSEC validation    |
+----------+-----------+
           |
           v
 Root -> TLD -> Authoritative DNS

BIND is never published on the Docker host. Only AdGuard can query it directly.

Component Role
AdGuard Home Filtering, client policies, query logs, DNS frontend
BIND 9 Recursive resolution, cache, DNSSEC validation
Docker network Private communication between AdGuard and BIND

Highlights

  • AdGuard Home DNS filtering
  • Private BIND 9 recursive resolver
  • DNSSEC validation enabled
  • No public recursive DNS upstream required
  • BIND isolated from the host network
  • Restricted recursion/cache access
  • Persistent AdGuard configuration
  • Docker log rotation and resource limits
  • BIND health check and startup ordering
  • Validation, backup, update and migration scripts
  • Optional home.arpa local DNS examples
  • GitHub Actions configuration validation

Requirements

  • Linux Distro
  • Docker Compose v2
  • A stable IP address
  • TCP/UDP port 53 available

Useful tools:

sudo apt update
sudo apt install -y ca-certificates curl dnsutils

Networking step from v1

After configuring a fixed IP address, the original v1 setup removed the DHCP client and rebooted:

sudo apt remove isc-dhcp-client -y
sudo reboot

Make sure the server already has its intended static network configuration before running this step.

Check whether port 53 is already in use:

sudo ss -lntup | grep ':53'

Quick start

Clone the repository:

git clone https://github.com/1posix/adguard-bind9.git
cd adguard-bind9

Create your local configuration:

cp .env.example .env
nano .env

Set at least:

DNS_BIND_IP=192.168.1.10
WEB_BIND_IP=192.168.1.10

Replace 192.168.1.10 with the IP address of your Debian host.

The internal Docker addresses are fixed by default:

BIND     172.30.0.3
AdGuard  172.30.0.4

If 172.30.0.0/24 conflicts with an existing network, adapt the subnet and static addresses in compose.yaml and the AdGuard ACL in config/bind9/named.conf.options.

Run the preflight checks:

./scripts/preflight.sh

Start the stack:

docker compose pull
docker compose up -d
docker compose ps

BIND should become healthy before AdGuard starts.

Configure AdGuard Home

For a fresh installation, open:

http://SERVER_IP:3000/

Complete the setup wizard and create your administrator account.

Then open the normal interface:

http://SERVER_IP/

Go to Settings -> DNS settings and configure:

Upstream DNS servers:
172.30.0.3:53

Fallback DNS servers:
(empty)

Bootstrap DNS servers:
(empty)

The expected resolution path is:

Client -> AdGuard -> BIND -> Root/TLD/Authoritative DNS

Validate the stack

Run the end-to-end test:

./scripts/test-dns.sh

It verifies normal DNS resolution through AdGuard and performs a DNSSEC negative test with dnssec-failed.org.

A SERVFAIL response for that deliberately broken DNSSEC domain is expected.

Manual tests:

dig @192.168.1.10 example.org A
dig @192.168.1.10 dnssec-failed.org A

Replace 192.168.1.10 with your DNS_BIND_IP.

Migrating from v1

Keep a backup of the old project before starting.

Stop the old stack:

cd /path/to/old/adguard-bind9
docker compose down

From the v2 directory:

./scripts/migrate-v1.sh /path/to/old/adguard-bind9

The migration helper keeps the existing AdGuard configuration and runtime data while replacing the old BIND configuration with the v2 resolver setup.

Then:

./scripts/preflight.sh
docker compose up -d
./scripts/test-dns.sh

Keep the old project until DNS resolution, filtering and the AdGuard interface have been verified.

Common operations

Status:

docker compose ps

Logs:

docker compose logs -f --tail=100 adguardhome
docker compose logs -f --tail=100 bind9

Validate configuration:

./scripts/validate.sh

Restart:

docker compose restart

Stop / start:

docker compose down
docker compose up -d
Backups and updates

Configuration backup:

./scripts/backup.sh config

Full AdGuard backup:

./scripts/backup.sh full

Backups are stored in backups/.

Image versions are configured in .env, for example:

ADGUARD_IMAGE=adguard/adguardhome:v0.107.78
BIND_IMAGE=ubuntu/bind9:9.20-26.04_stable

After changing an image version:

./scripts/update.sh
./scripts/test-dns.sh

Prefer deliberate version updates over unpinned latest images.

Local DNS

BIND can also provide optional local DNS using the RFC 8375 reserved domain home.arpa.

A complete generic example is available in:

examples/bind9/home.arpa/
├── db.home.arpa.example
├── db.192.168.1.example
└── named.conf.local.example

The example contains both:

  • a forward zone: hostname → IP address
  • a reverse zone: IP address → hostname

Generic records can be adapted to any home, lab or small-office network:

gateway.home.arpa
dns.home.arpa
server.home.arpa
nas.home.arpa
printer.home.arpa
client.home.arpa

For example:

server.home.arpa  -> 192.168.1.10
192.168.1.10      -> server.home.arpa

Copy and adapt the example files to your own subnet, hostnames and addresses, then declare the zones in config/bind9/named.conf.local.

Validate the configuration before restarting BIND:

./scripts/validate.sh
docker compose restart bind9

Private production zones should stay out of the public repository.

Security

  • BIND is not published directly on the Docker host.
  • BIND recursion/cache access is restricted to AdGuard and localhost.
  • Do not expose the AdGuard administration interface to the Internet.
  • Only allow DNS access from trusted LAN/VLAN networks.
  • Keep .env, AdGuard runtime data, backups and private DNS zones out of Git.
  • Keep AdGuard Home and BIND updated after reviewing stable releases.

Project structure

.
├── compose.yaml
├── .env.example
├── .gitignore
├── VERSION
├── CHANGELOG.md
├── config/bind9/       # BIND configuration
├── data/adguard/       # Persistent AdGuard data
├── examples/bind9/     # Optional local DNS examples
├── scripts/            # Validation / backup / update tools
└── .github/workflows/  # CI validation

References

Upstream

This repository is based on the original project:

Version 2 keeps the original goal — running AdGuard Home and BIND together — while redesigning the stack for stronger isolation, validation, DNSSEC and maintainability.

About

Self-hosted DNS stack combining AdGuard Home filtering with a private BIND 9 recursive resolver, DNSSEC validation and Docker hardening.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages