Local DNS: reaching your services by name, without hacking hosts files

A clean internal domain, resolved locally and from the outside, with no duplicated entries. How split-horizon works, the made-up-domain trap, and why your browser sometimes ignores your DNS.

At first you just remember the addresses. The NAS at .20, the hypervisor at .10, the monitoring stack at .35. Then the services multiply, ports get added, and you end up keeping a list in a text file.

The next step is usually the hosts file, duplicated on every machine. It works — until the third machine, or the first address change.

The principle: a resolver that is authoritative

The answer is to run a resolver on your network that is authoritative for your internal domain. Every machine uses it as its DNS server, handed out automatically by DHCP.

It answers for your internal names itself, and forwards everything else upstream. A single change there propagates instantly to the whole network. No more hosts files, no more duplication.

It is also the natural place for network-wide filtering, if you want any — the same tools usually do both.

The made-up-domain trap

Then comes the question of the name. The temptation is to invent an extension: something in .lan, .home or .local, which sounds right and costs nothing.

That is a bad idea, for two distinct reasons.

First, an extension that is not delegated today can be assigned publicly tomorrow. Your internal names then collide with real internet names, with symptoms that make no sense and vary depending on which resolver was asked. This is not theoretical: several extensions widely used internally ended up existing publicly.

Second, some extensions are already reserved for other purposes by the standards — notably for service discovery on the local network — and using them for regular DNS causes erratic behavior, particularly on Apple systems.

The clean answer: a subdomain of a domain you own. You control the name, nobody will take it away from you, and it opens the door to publicly trusted certificates.

Side benefit: with a real domain, you can obtain valid public TLS certificates for your internal services — no security warnings, and no homegrown certificate authority to install everywhere.

Split-horizon: one name, two answers

The mechanism that makes the whole thing comfortable is split-horizon: the same name answers differently depending on where you ask from.

From home, the internal resolver returns the service's private address: traffic stays local and fast, and never leaves the network. From anywhere else, public DNS returns the public address and you come in through the intended path.

The benefit is having only one address to remember. Your bookmarks work at home and on the road, with no second set of links to maintain.

It also avoids a common oddity: without it, a machine on the network that asks for the public name gets the public address, leaves the network and comes back in — which sometimes works, often fails depending on the gear, and always hurts performance.

Certificates, without the warnings

A point that often surprises people: a certificate attests to a name, not to an address. If your browser asks for a name the certificate covers, validation succeeds — whether that name resolves to a private address is irrelevant.

So you can obtain a publicly trusted certificate for a service that is never exposed to the internet. The only constraint is to use DNS validation rather than HTTP validation, since the authority cannot reach your service.

It is the simplest way to get clean HTTPS internally, without pushing a homegrown certificate authority onto every device — an exercise that gets painful fast as soon as you add phones, or devices whose certificate store you do not control.

Two operational traps

The browser's encrypted DNS. Modern browsers can send their DNS queries straight to a public resolver, bypassing the system's. Your internal names then stop resolving — but only in the browser. Resolution still works on the command line, which makes the diagnosis disorienting. You have to disable the feature, or point it at your own resolver.

The single resolver. If it goes down, nothing resolves on the network any more, public names included. The symptom looks like a total internet outage while the connection is working perfectly. Two resolvers handed out by DHCP remove that risk. Failing that, at least keep access by IP address to your critical gear: the day DNS goes down, that is your only way in.

The order to roll it out

Start by declaring a subdomain on a domain you own. Then install the resolver and create a few test records, without touching DHCP. Check resolution by querying that resolver explicitly. Only once that is conclusive do you hand it out over DHCP to the whole network — and you add the second one at the same time, while you are at it.

Frequently asked questions

Which domain should I use for my internal network?
A subdomain of a domain you genuinely own, something like lan.mydomain.com. Do not invent an extension: undelegated extensions can be assigned publicly at any moment, and your internal names would then collide with real internet names. It has already happened to extensions that were widely used internally. A subdomain you control costs you the price of a domain and puts the problem behind you for good.
What is split-horizon DNS and what is it for?
It is the fact that the same name answers differently depending on where the query comes from: your internal resolver returns the service's private address, while public DNS returns the public one. The point is to have a single address to remember, one that works just as well at home as away, and to avoid pushing local traffic out and back in through the external loop.
Can I use a public certificate on a private IP address?
Yes, with no difficulty at all. A certificate attests to a domain name, not to an address. If your browser asks for nas.lan.mydomain.com and the certificate covers that name, validation succeeds — the fact that the name resolves to a private address is irrelevant. You simply have to obtain the certificate through DNS validation, since the service is not reachable from the internet.
Why do my internal names no longer resolve in the browser?
Because the browser is probably using encrypted DNS configured independently of the system. It sends its queries straight to a public resolver, bypassing yours entirely — and that resolver obviously knows nothing about your internal names. The symptom is disorienting: resolution works on the command line but fails in the browser. The fix is to turn the feature off, or to point the browser at the system resolver.
Is one resolver enough, or do I need redundancy?
A single resolver becomes a major point of failure: if it goes down, nothing resolves on the network — public names included — and the symptom looks exactly like a complete internet outage. Two resolvers handed out by DHCP settle the question. Failing that, at least make sure the resolver does not depend on a service you restart often, and keep a fallback path by IP address to your critical gear.

Did you enjoy this article?

Comments

Morgann Riu

Cybersecurity and Linux administration expert. I help companies secure and optimize their critical infrastructures.

Back to the blog

Checklist Sécurité Linux

30 points essentiels pour sécuriser un serveur Linux. Recevez aussi les nouveaux tutoriels par email.

Pas de spam. Désabonnement en 1 clic.