All posts

Standing Up Internal DNS with BIND

Updated November 26, 2026

A central hub with a branching tree of paths resolving to many small service cubes

By the end of May I had dozens of services running and I was reaching every one of them by typing an IP address and a port number from memory.

That works until it doesn't. Containers get new addresses when they are recreated. A service moves to another host. A config file somewhere still points at the old address, and the failure shows up as a vague timeout two systems away. I wanted names. So late on a Friday night (my notes are timestamped just after midnight on May 31) I started building internal DNS (the system that turns names into addresses), and by Sunday it was answering for every client on the network.

Two Kinds of DNS, Kept Apart

The first decision was to keep internal and public DNS separate.

Public DNS for my domain already lived with a hosted DNS provider. Keeping the two views apart, one for the outside world and one for my own network, is called split-horizon DNS. I'd never heard the term before I built this. That's where the outside world looks things up, and it should only know about the few things the outside world is allowed to reach. Internal DNS is the opposite: it can name every server, database and dashboard, because only machines on my own networks can ask it anything. Mixing the two means either leaking internal names to the internet or making internal resolution depend on an outside service. Neither is acceptable.

So the design was: BIND (the DNS server software) for everything internal, the hosted provider for the handful of public names.

Where BIND Should Run

My first plan put BIND on the firewall itself. OPNsense can run it as a plugin (an add-on package), and the firewall is already the box every client talks to. I wrote a full configuration for that version, with access lists for each internal network.

I changed course before deploying it. The firewall is the one device I want doing as little as possible. With only one physical firewall, it's a single point of failure, and every extra service on it's one more thing that can affect routing for the whole network. I had ample hardware, so a service like DNS belonged in a container instead. There was a second benefit. With BIND running in its own container, apart from the firewall, I could still reach my internal services by name even when the firewall had trouble connecting to the internet.

My Docker host was already managed through Portainer, with configuration in version control and a clean way to redeploy. Running BIND as a container there kept the firewall simple and gave the DNS server the same deployment and rollback path as everything else.

I didn't take DNS off the firewall entirely. OPNsense still runs Unbound, its built-in resolver, as a lightweight forwarder. What I decided against was running BIND on it.

The tradeoff: BIND couldn't take the standard DNS port (53), so it listens on 5353. Something on the host already held port 53, so BIND listened on 5353 instead. That turned out not to matter, because clients never talk to BIND directly. More on that below.

Organizing the Zones

I split the internal namespace by function, with one zone per group:

  • management (hypervisors, the firewall, container management)
  • backend services (databases, caches, the secrets store, source control)
  • user-facing applications
  • AI and model services
  • public-facing services in the DMZ (the separate network segment for anything the internet may reach)
  • security tooling
  • wireless and IoT (internet-of-things devices)
  • a reverse zone, so addresses resolve back to names

Eight zones and a little over a hundred records by the end of the weekend. Splitting by function means a name tells you what a thing is before you look it up: anything under the management zone is infrastructure, and access rules can follow the same lines. It also keeps each zone file short enough to read in one screen.

I built these zones before I had VLANs. The VLANs eventually took over the job the zones were doing, which was separating machines by function. A zone file for this layout looks like this, with placeholder names and documentation addresses:

$TTL 3600
@       IN  SOA ns1.mgmt.example.internal. admin.example.internal. (
            2025060101 ; serial
            3600       ; refresh
            900        ; retry
            604800     ; expire
            300 )      ; negative cache
        IN  NS  ns1.mgmt.example.internal.
ns1     IN  A   192.0.2.53
pve01   IN  A   192.0.2.10
fw01    IN  A   192.0.2.1
portal  IN  CNAME vm-app.apps.example.internal.

One practical rule from that weekend: increment the serial every time you edit a zone, or secondaries and caches will keep serving the old data.

Locking It Down

An internal DNS server should only answer internal clients. The settings I cared about:

  • allow-query and allow-recursion limited to my internal networks, so the server is useless to anyone outside them.
  • Zone transfers disabled. There was no secondary to transfer to, so nothing needed them.
  • The BIND version string hidden, so a query doesn't hand out the exact software version.
  • Dynamic updates off. Records changed only by editing the zone files, which are under version control.
  • Query logging on, which made testing much easier: every lookup from a client showed up in the log.

Before every reload, the configuration and each zone get checked:

named-checkconf /etc/bind/named.conf
named-checkzone mgmt.example.internal /etc/bind/zones/mgmt.example.internal.db

Both commands catch the typo that would otherwise take a zone offline.

Getting Clients to Use It

My first plan was to hand out the BIND server through DHCP (the service that assigns addresses) on every VLAN, with a public resolver listed as a fallback. That plan has a problem. Clients don't use a "fallback" in order. Many of them pick whichever server answers, and a public resolver will happily tell them an internal name doesn't exist. That's the kind of intermittent failure that eats a support afternoon.

The final design kept the firewall as the only DNS server clients know about. Unbound on OPNsense forwards queries for the internal domains to BIND (that's where the non-standard port gets specified, once, in one place) and resolves everything else itself. Client query, firewall, BIND, answer, back through the firewall. Nothing to change on any client, and one place to look when something fails.

Testing From a Real Client

Server-side tests prove BIND answers. They don't prove a laptop can use it. I tested from my MacBook Pro, which is where most of my work happens, and checked five things: names in the infrastructure zone, names in the application zone, a CNAME that points across zones, a reverse lookup, and an ordinary public name to make sure outside resolution still worked. All five passed.

Two macOS details are worth knowing here. dig and nslookup talk to DNS servers directly and skip the macOS resolver, so they can succeed while an app still fails. To see what apps actually get:

dscacheutil -q host -a name pve01.mgmt.example.internal

And macOS caches answers, including failures from before the record existed. Clear it after a change:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

One more: don't use .local for an internal domain. Macs treat it as Bonjour (multicast DNS) and may never send those queries to your DNS server at all.

What Comes Next

With names in place, the direction was clear. Next came replacing the hardcoded container addresses in my reverse proxy configuration with these names, so a recreated container wouldn't break the proxy. The public side got its own piece: a dynamic DNS updater with an API token scoped to editing DNS records for that one domain, so the public names would follow the address my ISP (internet service provider) assigns me.

What I'd Tell Someone Doing This Tomorrow

Decide the split first: what the internet may know, and what only your own networks may know. Then organize internal zones by function, keep the zone files in version control, and run named-checkconf and named-checkzone before every reload. Make the firewall or router the one DNS server clients see and let it forward internal zones to the authoritative server. And test from a real client, with the tool that uses the same resolver path as the apps on that client.

About the author

Carlos Mendez

Carlos Mendez

IT support and systems, Maui, Hawaii

I come from IT support and systems work. I build and run my own infrastructure and the production websites for West Maui Tech, my business, and I build AI tooling on top of that stack. I write here about what I run, what broke, and how I fixed it.

Enjoyed this article?

Subscribe to get notified about new posts on software engineering, AI development, and infrastructure.

No spam, unsubscribe anytime.