Setting Up BIND9 on Ubuntu via Portainer
BIND9 (Berkeley Internet Name Domain version 9) is a widely used, open-source DNS server that translates domain names into IP addresses, manages DNS zones, and supports features like forwarding, caching, and zone delegation.
1. Prepare host directory
sudo mkdir -p /opt/bind9/etc
sudo mkdir -p /opt/bind9/zones
sudo chown -R root:root /opt/bind9
sudo chmod -R 755 /opt/bind92. Disable systemd-resolved
sudo systemctl stop systemd-resolved
sudo systemctl disable systemd-resolved3. Create config files
Create config file /opt/bind9/etc/named.conf.options (forwarding):
options {
directory "/var/cache/bind";
recursion yes;
allow-query { any; };
forwarders {
8.8.8.8;
8.8.4.4;
};
dnssec-validation no;
auth-nxdomain no;
listen-on { any; };
};Create zone‑config file /opt/bind9/etc/named.conf.local
zone "example.local" {
type master;
file "/etc/bind/zones/db.example.local";
};Create zone file /opt/bind9/zones/db.example.local
$TTL 604800Get Wang Levine’s stories in your inbox
Join Medium for free to get updates from this writer.
@ IN SOA ns1.example.local. admin.example.local. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS ns1.example.local.
ns1 IN A 192.168.1.10
www IN A 192.168.1.10
Change IPs and names as needed.
4. Deploy BIND9
In Portainer:
- Go to Containers → Add container.
- Name:
bind9. - Image:
ubuntu/bind9:latest. - Ports:
53TCP →5353UDP →53 - Volumes (bind‑mounts):
Host/opt/bind9/etc/named.conf.options→ Container/etc/bind/named.conf.options(read‑only)
Host/opt/bind9/etc/named.conf.local→ Container/etc/bind/named.conf.local(read‑only)
Host/opt/bind9/zones→ Container/etc/bind/zones(read‑only) - Restart policy: Always.
- Click Deploy the container.
5. Test from host or another machine
dig @YOUR_SERVER_IP google.com
nslookup ns1.example.local YOUR_SERVER_IP
nslookup www.example.local YOUR_SERVER_IP


