| 1 |
# atomdns |
| 2 |
|
| 3 |
atomdns is a DNS server/router, written in Go, that chains handlers. Each handler performs a (DNS) function. |
| 4 |
Its architecture is identical to HTTP servers with middleware. The order of the handlers in the configuration |
| 5 |
determines the order in which they are executed. (If you know CoreDNS; you might know that it has a fixed |
| 6 |
order - atomdns is _different_). |
| 7 |
|
| 8 |
atomdns is a rock-solid replacement for CoreDNS, BIND9, Knot, NSD, etc. This is not a toy example on how to |
| 9 |
use the dns library. atomdns is a fast and flexible DNS server. The key word here is _flexible_: with atomdns |
| 10 |
you are able to do what you want with your DNS data by utilizing handlers. If some functionality is not |
| 11 |
provided out of the box, you can add it by writing a handler. |
| 12 |
|
| 13 |
But why another server? Personally I felt that CoreDNS went all "the cloud way", without properly laying the |
| 14 |
basis for a DNS server that I want to run at home, there was also a lot of code duplication that was solved by |
| 15 |
writing miekg/dnsv2. And I needed a server to develop miekg/dnsv2 in tandem with the library. |
| 16 |
|
| 17 |
See <https://atomdns.miek.nl> for more complete docs. |
| 18 |
|
| 19 |
atomdns can: |
| 20 |
|
| 21 |
- Serve zone data from a file; with DNSSEC support (_dbfile_), plus: |
| 22 |
- Zone transfers and notifies. |
| 23 |
- DNSSEC signing (_sign_). |
| 24 |
- Provide query logging (_log_). |
| 25 |
- Access control for queryes (_acl_). |
| 26 |
- Provide metrics (by using Prometheus) (_metrics_). |
| 27 |
- Serve from a SQLite database (_dbsqlite_). |
| 28 |
- ... and more. |
| 29 |
- Serve as a router to router queries to some other (recursive) nameserver (_route_). [TODO] |
| 30 |
|
| 31 |
Each of these handlers has its own manual page, i.e. see atomdns-dbfile(7) for more information on the |
| 32 |
_dbfile_ handler for instance. These are generated from the (extensive) READMEs each handler must have. |
| 33 |
|
| 34 |
## Compilation from Source |
| 35 |
|
| 36 |
To compile atomdns, we assume you have a working Go setup. See various tutorials if you don’t have that |
| 37 |
already configured. We follow upstream Go closely and use new language features when they come available. |
| 38 |
|
| 39 |
``` |
| 40 |
$ git clone https://codeberg.org/miekg/dns |
| 41 |
$ cd dns/cmd/atomdns |
| 42 |
$ go build |
| 43 |
``` |
| 44 |
|
| 45 |
This should yield a `atomdns` binary. |
| 46 |
|
| 47 |
## Examples |
| 48 |
|
| 49 |
The configuration of atomdns is done through a file named `Conffile`. When atomdns starts, it will look for |
| 50 |
the `Conffile` from the current working directory. A `Conffile` for atomdns server that listens on port `1053` |
| 51 |
and enables `whoami` handler is: |
| 52 |
|
| 53 |
```conffile |
| 54 |
{ |
| 55 |
dns { |
| 56 |
addr [::]:1053 |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
. { |
| 61 |
whoami |
| 62 |
} |
| 63 |
``` |
| 64 |
|
| 65 |
Then start `./atomdns -c Conffile`. |
| 66 |
|
| 67 |
Or use `Conffile-example` which has a more complete setup. |
| 68 |
|
| 69 |
./atomdns -c Conffile-example |
| 70 |
|
| 71 |
When atomdns starts you are greeted (when not using `quiet`) a bunch of log lines and a welcome banner: |
| 72 |
|
| 73 |
```txt |
| 74 |
2025/12/18 13:30:03 INFO 0.0.10.in-addr.arpa. handlers=log,whoami |
| 75 |
2025/12/18 13:30:03 INFO example.org. handlers=id,log,dbfile |
| 76 |
2025/12/18 13:30:03 INFO miek.nl. handlers=log,metrics,sign,dbfile |
| 77 |
2025/12/18 13:30:03 INFO Startup functions total=14 |
| 78 |
2025/12/18 13:30:03 INFO Startup handler=global /health=:8080 |
| 79 |
2025/12/18 13:30:03 INFO Startup handler=global health="overload check" |
| 80 |
2025/12/18 13:30:03 INFO Startup handler=global /metrics=localhost:9153 /N=10 |
| 81 |
2025/12/18 13:30:03 INFO Startup handler=global dns=[::]:1053 tcp=-1 run=24 |
| 82 |
2025/12/18 13:30:03 INFO Startup handler=global doh=[::]:1443 run=8 inflight=100 path=/dns-query |
| 83 |
2025/12/18 13:30:03 INFO Startup handler=global dot=[::]:8053 tcp=1024 run=1 inflight=200 |
| 84 |
2025/12/18 13:30:03 INFO Startup handler=global tls=manual |
| 85 |
2025/12/18 13:30:03 INFO Startup handler=global signal=HUP |
| 86 |
2025/12/18 13:30:03 INFO Startup handler=log signal=USR1 |
| 87 |
2025/12/18 13:30:03 INFO Startup handler=dbfile reload=db.example.org |
| 88 |
2025/12/18 13:30:03 INFO Startup handler=sign signing=db.miek.nl |
| 89 |
2025/12/18 13:30:03 INFO Days left before expiration handler=sign zone=miek.nl. path=db.miek.nl.signed days=36 |
| 90 |
2025/12/18 13:30:03 INFO Startup handler=dbfile reload=db.miek.nl.signed |
| 91 |
2025/12/18 13:30:03 INFO Build GOOS=linux GOARCH=arm64 go=1.25.5 revision=79e3ca30a4364da296eb74ab67ae04a184166e5a |
| 92 |
2025/12/18 13:30:03 INFO Listening roles=DNS:[::]:1053,DOH:[::]:1443,DOT:[::]:8053 |
| 93 |
2025/12/18 13:30:03 INFO Launched config=Conffile-example PID=3325169 version=v058 dns=0.6.5 zones=3 |
| 94 |
┏━┓ ╺┳╸ ┏━┓ ┏┳┓ |
| 95 |
┣━┫ ┃ ┃ ┃ ┃┃┃ DNS |
| 96 |
╹ ╹ ╹ ┗━┛ ╹ ╹ v058 (0.6.5) |
| 97 |
High performance and flexible DNS server |
| 98 |
https://atomdns.miek.nl |
| 99 |
__________________________________\o/_______ |
| 100 |
``` |
| 101 |
|
| 102 |
Where the last INFO lines shows the config parsed, the number of origins processed and for which protocols the |
| 103 |
server can answer, here: DNS, DOH (DNS over HTTPS) and DOT (DNS over TLS) and on which ports. |
| 104 |
|
| 105 |
See atomdns-conffile(7) for more information. For a more total experience head over to |
| 106 |
<https://atomdns.miek.nl>. |