RogerBW's Blog

Modern Internal Nameservice 27 January 2025

Not many people run their own internal DNS any more. For people who do, here's now I do it.

Of course in the old days everyone used BIND, but there's better now. The basic approach is twofold:

  • nsd for authoritative service of local zones

  • unbound for a "public" resolver (i.e. visible to the rest of the network)

Both of these are configured by default to use all interfaces. So a bit of careful setup is needed. I'm using Debian/stable (v12, bookworm, at the time of writing).

I assume your local zone is LOCALZONE (in my case homenet.firedrake.org).

nsd

Bind it to localhost: /etc/nsd/nsd.conf.d/server.conf

server:
        ip-address: 127.0.0.1
        ip-address: ::1
        username: nsd
        xfrdfile: "/var/lib/nsd/xfrd.state"

Set up local zone(s):/etc/nsd/nsd.conf.d/main.zones.conf:

zone:
        name: "LOCALZONE"
        zonefile: "db.LOCALZONE"
        provide-xfr: 10.0.0.0/8 NOKEY
        provide-xfr: 127.0.0.1 NOKEY
        provide-xfr: ::1/128 NOKEY

(On theory this should only need localhost addresses but it didn't work for me until I put in the local net too.) Similarly with 10.in-addr.arpa

Stick the zonefiles in /etc/nsd/ . These are standard BIND-type zonefiles.

unbound

Set up access addresses: /etc/unbound/unbound.conf.d/something.conf;

server:
        interface: 10.0.0.100
        interface: 2001:[my public IPv6 address]
        access-control: 10.0.0.0/8 allow
        access-control: 172.16.0.0/12 allow
        [and IPv6 too]
        do-not-query-localhost: no
        domain-insecure: LOCALZONE

local-zone: "10.in-addr.arpa." nodefault

Then enable the zones served by nsd as stub zones in the same file.

stub-zone:
        name: "LOCALZONE"
        stub-addr: 127.0.0.1
        stub-no-cache: yes

If you have an external server you want to use as a forwarder:

forward-zone:
        name: "."
        forward-addr: FORWARDER-ADDRESS

Then point all other hosts to this one as the resolver. If you want to be able to resolve from outside (e.g. over a VPN) you'll need glue records, but no need if this is for purely internal use.

When you update the local zone, run

nsd-control reload LOCALZONE

and then

unbound-control flush_zone LOCALZONE

Tags: computing

Add A Comment

Your Name
Your Email
Your Comment

Your submission will be ignored if any field is left blank, but your email address will not be displayed. Comments will be processed through markdown.

Search
Archive
Tags 1920s 1930s 1940s 1950s 1960s 1970s 1980s 1990s 2000s 2010s 2300ad 3d printing action advent of code aeronautics aikakirja anecdote animation anime army astronomy audio audio tech base commerce battletech bayern beer boardgaming book of the week bookmonth chain of command children chris chronicle church of no redeeming virtues cold war comedy computing contemporary cornish smuggler cosmic encounter coup covid-19 crime crystal cthulhu eternal cycling dead of winter doctor who documentary drama driving drone ecchi economics en garde espionage essen 2015 essen 2016 essen 2017 essen 2018 essen 2019 essen 2022 essen 2023 essen 2024 existential risk falklands war fandom fanfic fantasy feminism film firefly first world war flash point flight simulation food garmin drive gazebo genesys geocaching geodata gin gkp gurps gurps 101 gus harpoon historical history horror hugo 2014 hugo 2015 hugo 2016 hugo 2017 hugo 2018 hugo 2019 hugo 2020 hugo 2021 hugo 2022 hugo 2023 hugo 2024 hugo-nebula reread in brief avoid instrumented life javascript julian simpson julie enfield kickstarter kotlin learn to play leaving earth linux liquor lovecraftiana lua mecha men with beards mpd museum music mystery naval noir non-fiction one for the brow opera parody paul temple perl perl weekly challenge photography podcast politics postscript powers prediction privacy project woolsack pyracantha python quantum rail raku ranting raspberry pi reading reading boardgames social real life restaurant reviews romance rpg a day rpgs ruby rust scala science fiction scythe second world war security shipwreck simutrans smartphone south atlantic war squaddies stationery steampunk stuarts suburbia superheroes suspense television the resistance the weekly challenge thirsty meeples thriller tin soldier torg toys trailers travel type 26 type 31 type 45 vietnam war war wargaming weather wives and sweethearts writing about writing x-wing young adult
Special All book reviews, All film reviews
Produced by aikakirja v0.1