Setup bind9
No Longer Active
Overview
BIND 9 has evolved to be a very flexible, full-featured DNS system. Whatever your application is, BIND 9 probably has the required features.
Important bind9 Files
Zone Files
Zone File
$TTL 60;
@ IN SOA ns. . (
2024012002 ; serial number
900 ; refresh
300 ; update retry
604800 ; expiry
900 ; nx = nxdomain ttl
)
; only one NS is required for this local file
; and is an out of zone name
IN NS ns.
ns IN CNAME hostname
Subdomain IN A 0.0.0.0
Subdomain IN CNAME hostname.
named.conf file
named.conf
acl lan {
10.1.10.0/24;
10.1.20.0/24;
};
acl docker {
172.18.0.0/16; # Proxy
172.19.0.0/16; # Internal
172.20.0.0/16; # Internal Databases
};
acl tailscale {
100.64.0.0/10;
};
view "Local" {
match-clients {
lan;
};
zone "local.jonco.dev" IN {
type master;
file "/etc/bind/zones/lan.zone";
};
};
view "Tailscale" {
match-clients {
any;
};
zone "local.jonco.dev" IN {
type master;
file "/etc/bind/zones/wan.zone";
};
};
key "rndc-key" {
algorithm hmac-sha256;
secret "EXADKKYtEvz6gO0Wl7dkuQXzr7Oupn66";
};
options {
directory "/var/cache/bind";
recursion yes;
listen-on {
any;
};
allow-query {
localhost;
lan;
tailscale;
docker;
};
forwarders {
8.8.8.8;
1.1.1.1;
};
}
Important Docker Files
.env file
.env
NAME=bind9
APPDATA=
TZ=America/New_York
docker-compose.yml file
docker-compose.yml
services:
bind9:
container_name: ${NAME}
restart: unless-stopped
image: ubuntu/bind9
environment:
TZ: ${TZ}
BIND9_USER: root
ports:
- 53:53/tcp
- 53:53/udp
networks:
- proxy
volumes:
- ${APPDATA}/${NAME}/config:/etc/bind
- ${APPDATA}/${NAME}/cache:/var/cache/bind
labels:
com.centurylinklabs.watchtower.enable: true
networks:
proxy:
external: true
Start the Container
Start the Container
docker compose up -d