TinyDNS Format

From Alpine Linux

TinyDNS data file

The offical data format for tinydns data is documented in https://cr.yp.to/djbdns/tinydns-data.html See notes at the bottom of this article for more information on certain fields.

SOA Record

`Zfqdn:nameserver:contactinfo:serial:retry:expire:min:ttl:timestamp:lo`

Zmy.example.net:208.210.221.65:abuse.example.net

Question: Zmy.example.net.
my.example.net. +2560 soa 208.210.221.65. abuse@example.net. 1206390017 16384 2048 1048576 2560

Zmy.example.net:208.210.221.65:abuse.example.net:2008032201:1000:2000:3000:4000

my.example.net. +2560 soa 208.210.221.65. abuse@example.net. 2008032201 1000 2000 3000 4000

A, NS record combined

`&fqdn:ip:x:ttl:timestamp:lo`

Creates an A and NS record. Typically used to delegate a subdomain. Can be used in combination with Z to accomplish the same thing as the combo above, but with a different email address.

&my.example.net:208.210.221.65:something:

# Question: Zmy.example.net.
# NS replies:
my.example.net. +259200 ns something.ns.my.example.net.
# AR replies:
#something.ns.my.example.net. +259200 a 208.210.221.65

&my.example.net:208.210.221.65:ns1.somewhere.com:3600

# Question: Zmy.example.net.
# NS replies:
my.example.net. +3600 ns ns1.somewhere.com.
# AR replies:
#ns1.somewhere.com. +3600 a 208.210.221.65

A and PTR record

`=fqdn:ip:ttl:timestamp:lo`

=alpha.my.example.net:192.168.1.1

Question: Zalpha.my.example.net.
alpha.my.example.net. +86400 a 192.168.1.1

# Question: Z1.1.168.192.in-addr.arpa.
1.1.168.192.in-addr.arpa. +86400 ptr alpha.my.example.net

For the PTR record to be returned, you must have the corresponding SOA record defined:

Zmy.example.net:ns1.my.example.net:abuse.example.net
&my.example.net:208.210.221.65:ns1.my.example.net

Z168.192.in-addr.arpa:ns1.my.example.net:abuse.example.net
&168.192.in-addr.arpa:208.210.221.65:ns1.my.example.net

A record

`+fqdn:ip:ttl:timestamp:lo`

+alpha.my.example.net:192.168.1.1

Question: Zalpha.my.example.net.
alpha.my.example.net. +86400 a 192.168.1.1

MX Record

`@fqdn:ip:x:dist:ttl:timestamp:lo`

@my.example.net:208.210.221.77:something

Question: @my.example.net.
my.example.net. +86400 mx 0 something.mx.my.example.net.

@my.example.net:208.210.221.77:mx1.my.example.net:10
@my.example.net:208.210.221.78:mx2.my.example.net:20

Question: @my.example.net.
my.example.net. +86400 mx 10 mx1.my.example.net.
my.example.net. +86400 mx 20 mx2.my.example.net.
# AR replies:
#mx1.my.example.net. +86400 a 208.210.221.77
#mx2.my.example.net. +86400 a 208.210.221.78

CNAME

`Cfqdn:x:ttl:timestamp:lo`

Cmailserver.my.example.net:yourmailserver.somewhere.com

Question: Zmailserver.my.example.net.
mailserver.my.example.net. +86400 cname yourmailserver.somewhere.com.

TXT

`'fqdn:s:ttl:timestamp:lo`

'my.example.net:Please do not bug us we know our DNS is broken

Question: Tmy.example.net
my.example.net. +86400 txt 'Please do not bug us we know our DNS is broken'

SRV

Sfqdn:ip:x:port:priority:weight:ttl:timestamp

Standard rules for ip, x, ttl, and timestamp apply. Port, priority, and weight all range from 0-65535. Priority and weight are optional; they default to zero if not provided.

Sconsole.zoinks.example.com:1.2.3.4:rack102-con1:2001:7:69:300:

query: 33 console.zoinks.example.com
answer: console.zoinks.example.com 300 SRV 7 69 2001 rack102-con1.example.com

NAPTR

`Nfqdn:order:pref:flags:service:regexp:replacement:ttl:timestamp`

The same standard rules for ttl and timestamp apply. Order and preference (optional) range from 0-65535, and they default to zero if not provided. Flags, service and replacement are character-strings. The replacement is a fqdn that defaults to '.' if not provided.

Nsomedomain.org:100:90:s:SIP+D2U::_sip._udp.somedomain.org

query: 35 somedomain.org
answer: somedomain.org 78320 NAPTR 100 90 "s" "SIP+D2U" "" _sip._tcp.somedomain.org

Ncid.urn.arpa:100:10:::!^urn\058cid\058.+@([^\.]+\.)(.*)$!\2!i:

AAAA

`:fqdn:28:location:ttl`

These records are used to resolve IPv6 addresses.

:alpha.my.example.net:28:\050\001\103\000\302\072\000\077\105\052\064\355\256\064\063\124:86400

query: alpha.my.example.net   IN         ANY
answer: alpha.my.example.net. 86400 IN	AAAA	2801:4300:c23a:3f:452a:34ed:ae34:3354

Notes

Each line starts with a character, and continues with colon separated fields. Spaces and tabs at the end of a line are ignored. Blank lines are also ignored.

timestamp is an optional TAI64 (hex format) timestamp. If the timestamp is given, TTL has special meaning:

  • If TTL is nonzero or is omitted, then the timestamp is when this record goes "live"
  • if TTL is zero, then the timestamp is the "time to die", when the record is no longer to be served. TinyDNS will dynamically adjust the TTL so that the DNS records are not cached beyond the "time to die"

lo is an optional location field. The record is ignored if the client is outside that location. lo can be one or two characters. For example,

%in:192.168
%ex
+www.mydomain.com:192.168.1.1:::in
+www.mydomain.com:200.20.32.1:::ex

specifies www.mydomain.com has address 192.168.1.1 for clients in the 192.168.0.0/16 address range, and 200.20.32.1 for all other clients.

In lines with "x", if "x" contains a dot, then "x" is used as the server name rather than "x".[something].fqdn You should omit ip if x has IP addresses assigned elsewhere in the data file.

Wildcards in the form of *.fqdn are allowed, and will resolve any address EXCEPT those that have their own records, or more specific wildcards.

+www.mydomain.com:200.3.1.1
+*.mydomain.com:127.0.0.1

Will send the user to his local machine for foo.mydomain.com, mx.mydomain.com, in fact, ANYTHING.mydomain.com, except www.mydomain.com