| 1 |
# Name |
| 2 |
|
| 3 |
_conffile_ - configuration file for atomdns |
| 4 |
|
| 5 |
# Description |
| 6 |
|
| 7 |
A _conffile_ specifies the handlers atomdns should chain. The syntax is as follows: |
| 8 |
|
| 9 |
```txt |
| 10 |
ZONE[/CLASS] [ZONE[/CLASS]]... { |
| 11 |
[HANDLER]... |
| 12 |
} |
| 13 |
``` |
| 14 |
|
| 15 |
Such a section is called a _handler block_. Each block defines the handlers this server should run |
| 16 |
when it gets a query for one the **ZONE**s. |
| 17 |
|
| 18 |
The **ZONE** defines for which zones this handler should be called, multiple zones are allowed and must be |
| 19 |
_white space_ separated. If **/CLASS** is not speficied in IN class is assumed, for CH class zones use |
| 20 |
**/CH**, IN and CH are the only supported classes at this point. |
| 21 |
|
| 22 |
When a query comes in, it is matched again all zones of all handlers blocks, the block with the longest match for the |
| 23 |
query name will receive the query and runs it through it's defined handlers. |
| 24 |
|
| 25 |
**HANDLER** defines the handlers(s) we want to load. This is optional as well, but a block with no handlers |
| 26 |
will just return REFUSED for all queries. Each handler can have a number of properties that can have |
| 27 |
arguments, see the documentation for each handler (atomdns-**HANDLER**(7)). |
| 28 |
|
| 29 |
The order of the **HANDLER**s is the order in which they are executed! (If you know CoreDNS, this is |
| 30 |
different, as which CoreDNS the order is fixed compile time). I.e. putting the _log_ handler (atomdns-log(7)) |
| 31 |
as last, means no queries are logged. |
| 32 |
|
| 33 |
Comments are allowed and begin with an unquoted hash `#` and continue to the end of the line. Comments may be |
| 34 |
started anywhere on a line. |
| 35 |
|
| 36 |
Environment variables are supported and either the Unix or Windows form may be used: `{$ENV_VAR_1}` or |
| 37 |
`{%ENV_VAR_2%}`. |
| 38 |
|
| 39 |
The `~` (tilde) character and path names will be expanded to the home directory of the current user. |
| 40 |
|
| 41 |
As an way to test things Conffile also supports a shorter way of writing things, but this only works for a |
| 42 |
single handler: |
| 43 |
|
| 44 |
```conffile |
| 45 |
ZONE[/CLASS] [ZONE[/CLASS]]... |
| 46 |
[HANDLER]... |
| 47 |
``` |
| 48 |
|
| 49 |
I.e. |
| 50 |
|
| 51 |
```txt |
| 52 |
example.org |
| 53 |
log |
| 54 |
whoami |
| 55 |
``` |
| 56 |
|
| 57 |
Or |
| 58 |
|
| 59 |
```txt |
| 60 |
example.org/IN |
| 61 |
log |
| 62 |
whoami |
| 63 |
``` |
| 64 |
|
| 65 |
Is a valid configuration and is supported by `atomdns`. |
| 66 |
|
| 67 |
# Global |
| 68 |
|
| 69 |
A Conffile must have a global block, this is a block without a zone and holds server wide |
| 70 |
options, like how many instances to run, if you want DOH and DOT servers, etc. etc. For each server type |
| 71 |
(DNS - plain DNS, DOT - DNS over TLS, DOH - DNS over HTTP, and DOU - DNS over Unix sockets) |
| 72 |
you have a section `dns`, `dot`, `doh` and `dou` where you can configure the server, most notably the |
| 73 |
address and port you want to listen on. |
| 74 |
|
| 75 |
```txt |
| 76 |
{ |
| 77 |
dns { |
| 78 |
addr [::]:1053 |
| 79 |
} |
| 80 |
root /var/lib/atomdns |
| 81 |
metrics localhost:9153 |
| 82 |
} |
| 83 |
``` |
| 84 |
|
| 85 |
Here we say we should only run a DNS server listening on port 1053 on all addresses, set the `root` directory |
| 86 |
to "/var/lib/atomdns" and enable metrics. See atomdns-global(7) for more information. |
| 87 |
|
| 88 |
# Import |
| 89 |
|
| 90 |
You can use the _import_ "handler" to include parts of other files, or snippets that are defined in the |
| 91 |
configuration file see atomdns-import(7). To prevent infinite recursion a maximum of a 1000 imports are allowed. |
| 92 |
|
| 93 |
# Snippets |
| 94 |
|
| 95 |
If you want to reuse a snippet you can define one with and then use it with _import_. |
| 96 |
|
| 97 |
```conffile |
| 98 |
(mysnippet) { |
| 99 |
log |
| 100 |
whoami |
| 101 |
} |
| 102 |
|
| 103 |
example.org { |
| 104 |
import mysnippet |
| 105 |
} |
| 106 |
``` |
| 107 |
|
| 108 |
# Examples |
| 109 |
|
| 110 |
The **ZONE** is root zone `.`, the **handler** is _chaos_. The _chaos_ handler takes an (optional) argument: |
| 111 |
`atomdns-001`. This text is returned on a CH class query: `dig CH TXT version.bind @localhost`. To only have |
| 112 |
this zone match the CH class, use **/CH**. |
| 113 |
|
| 114 |
```conffile |
| 115 |
./CH { |
| 116 |
chaos atomdns-001 |
| 117 |
} |
| 118 |
``` |
| 119 |
|
| 120 |
When defining a new zone, you either create a new block, or add it to an existing one. Here we define two |
| 121 |
blocks that each handle a different zone, that potentially chain different handlers: |
| 122 |
|
| 123 |
```conffile |
| 124 |
example.org { |
| 125 |
whoami |
| 126 |
} |
| 127 |
org { |
| 128 |
whoami |
| 129 |
} |
| 130 |
``` |
| 131 |
|
| 132 |
But this is identical to: |
| 133 |
|
| 134 |
```conffile |
| 135 |
example.org org { |
| 136 |
whoami |
| 137 |
} |
| 138 |
``` |
| 139 |
|
| 140 |
Reverse zones can be specified as domain names: |
| 141 |
|
| 142 |
```conffile |
| 143 |
0.0.10.in-addr.arpa { |
| 144 |
whoami |
| 145 |
} |
| 146 |
``` |
| 147 |
|
| 148 |
Or by just using the CIDR notation: |
| 149 |
|
| 150 |
```conffile |
| 151 |
10.0.0.0/24 { |
| 152 |
whoami |
| 153 |
} |
| 154 |
``` |
| 155 |
|
| 156 |
This also works on a non octet boundary: |
| 157 |
|
| 158 |
```conffile |
| 159 |
10.0.0.0/27 { |
| 160 |
whoami |
| 161 |
} |
| 162 |
``` |
| 163 |
|
| 164 |
Doing Let's Encrypt certificates for your DOH servers: |
| 165 |
|
| 166 |
```conffile |
| 167 |
{ |
| 168 |
root /var/lib/atomdns |
| 169 |
|
| 170 |
dns { |
| 171 |
addr [::]:1053 |
| 172 |
limits { |
| 173 |
tcp -1 |
| 174 |
run numcpu()*3 |
| 175 |
} |
| 176 |
} |
| 177 |
doh { |
| 178 |
addr [::]:10053 |
| 179 |
limits { |
| 180 |
run numcpu()*1 |
| 181 |
} |
| 182 |
} |
| 183 |
tls lets-encrypt { |
| 184 |
source eth0 |
| 185 |
contact [email protected] |
| 186 |
directory lets-encrypt |
| 187 |
} |
| 188 |
} |
| 189 |
|
| 190 |
example.net { |
| 191 |
log |
| 192 |
dbfile example.net |
| 193 |
} |
| 194 |
``` |
| 195 |
|
| 196 |
# Authors |
| 197 |
|
| 198 |
atomdns authors. |
| 199 |
|
| 200 |
# Copyright |
| 201 |
|
| 202 |
Apache License 2.0 |
| 203 |
|
| 204 |
# See Also |
| 205 |
|
| 206 |
The manual page for atomdns: atomdns(1) and the manual pages for the handlers. Particular atomdns-global(7) |
| 207 |
for the server parameters. |