<?xml version="1.0" encoding="UTF-8"?>
<!-- **************************************************************************
.... For copyright and licensing terms, see the file named COPYING.
.... **************************************************************************
.-->
<?xml-stylesheet href="docbook-xml.css" type="text/css"?>

<refentry id="tinydns-data">

<refmeta xmlns:xi="http://www.w3.org/2001/XInclude">
<refentrytitle>tinydns-data</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="manual">user commands</refmiscinfo>
<refmiscinfo class="source">djbwares</refmiscinfo>
<xi:include href="version.xml" />
</refmeta>

<refnamediv>
<refname>tinydns-data</refname>
<refpurpose>compile the database used by tinydns</refpurpose>
</refnamediv>

<refsynopsisdiv>
<cmdsynopsis>
<command>tinydns-data</command>
</cmdsynopsis>
</refsynopsisdiv>

<refsection>
<title>Description</title>

<para>
<command>tinydns-data</command> compiles a database in source form, in the file <filename>data</filename>, into a compiled form, in the file <filename>data.cdb</filename>, that is used by <citerefentry><refentrytitle>tinydns</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
The compiled database in <filename>data.cdb</filename> is a Bernstein Constant Database file, a write-once read-many binary file that provides much faster lookups than repeatedly parsing text files at runtime.
</para>
<caution>
The compiled database will change in a non-backwards-compatible way when <citerefentry><refentrytitle>tinydns</refentrytitle><manvolnum>1</manvolnum></citerefentry> and <citerefentry><refentrytitle>axfrdns</refentrytitle><manvolnum>1</manvolnum></citerefentry> support IPv6 client locations in a future release.
</caution>

<para>
<command>tinydns-data</command> updates <filename>data.cdb</filename> atomically, building a replacement in <filename>data.cdb.tmp</filename> and atomically renaming that replacement into place when it has completely and successfully built it it and written it to disc.
So you can use it safely while <citerefentry><refentrytitle>tinydns</refentrytitle><manvolnum>1</manvolnum></citerefentry> is running.
</para>

<para>
The expected workflow is to run <command>tinydns-data</command> every time that a change is made to <filename>data</filename>, tracking this with a utility such as <citerefentry><refentrytitle>make</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
For similar mechanisms elsewhere, compare <citerefentry><refentrytitle>pwd_mkdb</refentrytitle><manvolnum>1</manvolnum></citerefentry> for compiling the <citerefentry><refentrytitle>master.passwd</refentrytitle><manvolnum>5</manvolnum></citerefentry> file into a Berkeley DB file, and <citerefentry><refentrytitle>cap_mkdb</refentrytitle><manvolnum>1</manvolnum></citerefentry> for compiling various files such as <citerefentry><refentrytitle>login.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
</para>

</refsection>

<refsection>
<title>Data format</title>

<para>
The DNS information in <filename>data</filename> is a series of lines.
It is very easy for programs to edit; and can be mainpulated with with UNIX tools such as <citerefentry><refentrytitle>awk</refentrytitle><manvolnum>1</manvolnum></citerefentry> and <citerefentry><refentrytitle>sed</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
There is also a <citerefentry><refentrytitle>tinydns-edit</refentrytitle><manvolnum>1</manvolnum></citerefentry> tool for performing several common modifications, which handles updating the source <filename>data</filename> file itself atomically (something that otherwise needs to be done explicitly with the general-purpose text processing tools).
</para>

<para>
There are several types of lines, as shown below. 
</para>

<para>
Each line starts with a special character and continues with a series of colon-separated fields. 
In some cases the fields may be omitted; however, all colons must be included except at the end of the line. 
Spaces and tabs at the end of a line are ignored.
Blank lines are ignored. 
</para>

<refsection>
<title>IP addresses</title>

<para>
Many lines contain an <replaceable>ip</replaceable> field that is an IP address.
</para>

<para>
IPv4 addresses are written in the conventional human-readable form: 192.0.2.234, 10.20.40.80
</para>

<para>
IPv6 addresses are written in the conventional human-readable form, except that (since they are field separator characters here) colons are changed to underscores and the double-colon convention is not used.
All addresses must have all 8 groups: 2001_bd8_3_4_5_6_7_8, fd57_8012_f61c_0_20a2_9013_7ec4_7ab3
</para>

</refsection>

<refsection>
<title>Timestamps and scheduled changes</title>

<para>
Each line contains a <replaceable>ttl</replaceable> ("time to live") specifying the number of seconds that the line's DNS records may be cached.
Beware that cache times below 300 seconds will be treated as 300 by some clients, and NS cache times below 2 seconds can cause lookup failures.
You may omit <replaceable>ttl</replaceable>; <command>tinydns-data</command> will use default cache times, carefully selected to work well in normal situations.
</para>

<para>
You may include a timestamp on each line. 
If <replaceable>ttl</replaceable> is nonzero (or omitted), the timestamp is a starting time for the information in the line; the line will be ignored before that time.
If <replaceable>ttl</replaceable> is zero, the timestamp is an ending time ("time to die") for the information in the line; <command>tinydns</command> dynamically adjusts <replaceable>ttl</replaceable> so that the line's DNS records are not cached for more than a few seconds past the ending time.
A timestamp is an external TAI64 timestamp, printed as 16 lowercase hexadecimal characters.
</para>
<informalexample>
<para>
For example, the lines 
</para>
<programlisting>+www.heaven.af.example:192.0.2.234:0:4000000038af1379
+www.heaven.af.example:192.0.2.235::4000000038af1379
</programlisting>
<para>
specify that <filename>www.heaven.af.example</filename> will have address 192.0.2.234 until time 4000000038af1379 (2000-02-19 22:04:31 UTC) and will then switch to IP address 192.0.2.235. 
</para>
</informalexample>

</refsection>

<refsection>
<title>Client locations</title>

<para>
You may include a client location <replaceable>lo</replaceable> on each line. 
The line is ignored for clients outside that location. 
Client locations are specified by <code>%</code> lines: 
</para>
<para>
<programlisting> %<replaceable>lo</replaceable>:<replaceable>ipprefix</replaceable>
</programlisting>
means that IP addresses starting with <replaceable>ipprefix</replaceable> are in location <replaceable>lo</replaceable>. 
<replaceable>lo</replaceable> is a sequence of one or two ASCII letters. 
A client is in only one location; longer prefixes override shorter prefixes. 
</para>
<informalexample>
<para>
For example, 
</para>
<programlisting>%in:192.168
%ex
+jupiter.heaven.af.example:192.168.1.2:::in
+jupiter.heaven.af.example:192.0.2.234:::ex
+jupiter.heaven.af.example:3fff_0_1977_0905_1979_0305_1_2:::ex
</programlisting>
<para>
specifies that <filename>jupiter.heaven.af.example</filename> has address 192.168.1.2 for clients in the 192.168.* network and addresses 192.0.2.234 and 3fff:0:1977:905:1979:305:1:2 for everyone else.
</para>
</informalexample>

</refsection>

<refsection>
<title>Line types</title>

<variablelist>

<varlistentry>
<term>
<programlisting>#<replaceable>comment</replaceable>
</programlisting>
</term>
<listitem>
<para>
Comment line. 
The line is ignored. 
</para>
</listitem>
</varlistentry>

<varlistentry>
<term>
<programlisting>.<replaceable>fqdn</replaceable>:<replaceable>ip</replaceable>:<replaceable>x</replaceable>:<replaceable>ttl</replaceable>:<replaceable>timestamp</replaceable>:<replaceable>lo</replaceable>
</programlisting>
</term>
<listitem>
<para>
Apex name server for domain <replaceable>fqdn</replaceable>. 
<command>tinydns-data</command> creates 
<itemizedlist>
<listitem><para>
an NS ("name server") record showing <filename><replaceable>x</replaceable>.ns.<replaceable>fqdn</replaceable></filename> as a name server for <replaceable>fqdn</replaceable>; 
</para></listitem>
<listitem><para>
an A or AAAA ("address") record showing <replaceable>ip</replaceable> as the IP (4 or 6, respectively) address of <filename><replaceable>x</replaceable>.ns.<replaceable>fqdn</replaceable></filename>; and 
</para></listitem>
<listitem><para>
an SOA ("start of authority") record for <replaceable>fqdn</replaceable> listing <filename><replaceable>x</replaceable>.ns.<replaceable>fqdn</replaceable></filename> as the primary name server and <filename>hostmaster@<replaceable>fqdn</replaceable></filename> as the contact address. 
</para></listitem>
</itemizedlist>
</para>
<para>
You may have several name servers for one domain, with a different <replaceable>x</replaceable> for each server. 
You should omit <replaceable>ip</replaceable> if <replaceable>x</replaceable> has IP addresses assigned elsewhere in the data file; in this case, <command>tinydns-data</command> will omit the A record. 
</para>
<para>
If <replaceable>x</replaceable> contains a dot then <command>tinydns-data</command> will use <replaceable>x</replaceable> as the server name rather than <filename><replaceable>x</replaceable>.ns.<replaceable>fqdn</replaceable></filename>. 
</para>
<caution>
This feature is provided only for compatibility reasons; names not ending with <replaceable>fqdn</replaceable> will force clients to contact parent servers much more often than they otherwise would, and will reduce the overall reliability of DNS. 
The better <filename><replaceable>x</replaceable>.ns.<replaceable>fqdn</replaceable></filename> scheme, where <replaceable>x</replaceable> is a single letter, is designed to use in-bailiwick delegation and to take maximum advantage of the noddy compression scheme used by the DNS protocol so that as much of a large multi-nameserver delegation as possible can fit into a 512-octet DNS/UDP packet.
</caution>
<refsection><title>Examples</title>
<informalexample>
<programlisting>.panic.example:203.0.113.55:a
.panic.example:3fff_0_1978_0308_1980_0125_0102_55:a
</programlisting>
<para>
creates an NS record showing <filename>a.ns.panic.example</filename> as a name server for <filename>panic.example</filename>, an A record showing 203.0.113.55 as the IPv4 address of <filename>a.ns.panic.example</filename>, an AAAA record showing 3fff:0:1978:308:1980:125:102:55 as the IPv6 address of <filename>a.ns.panic.example</filename>, and an SOA record for <filename>panic.example</filename>. 
</para>
</informalexample>
<informalexample>
<programlisting>.panic.example:203.0.113.56:dns2.panic.example
.panic.example:3fff_0_1978_0308_1980_0125_0102_56:dns2.panic.example
</programlisting>
<para>
creates an NS record showing <filename>dns2.panic.example</filename> as a name server for <filename>panic.example</filename>, an A record showing 203.0.113.56 as the IPv4 address of <filename>dns2.panic.example</filename>, an AAAA record showing 3fff:0:1978:308:1980:125:102:56 as the IPv6 address of <filename>dns2.panic.example</filename>, and an SOA record for <filename>panic.example</filename>. 
</para>
</informalexample>
<informalexample>
<programlisting>.panic.example::a.ns.heaven.af.example
</programlisting>
<para>
creates an NS record showing <filename>a.ns.heaven.af.example</filename> as a name server for <filename>panic.example</filename>, and an SOA record for <filename>panic.example</filename>. 
</para>
</informalexample>
</refsection>
</listitem>
</varlistentry>

<varlistentry>
<term>
<programlisting>&#x26;<replaceable>fqdn</replaceable>:<replaceable>ip</replaceable>:<replaceable>x</replaceable>:<replaceable>ttl</replaceable>:<replaceable>timestamp</replaceable>:<replaceable>lo</replaceable>
</programlisting>
</term>
<listitem>
<para>
Delegation to name server for domain <replaceable>fqdn</replaceable>. 
<command>tinydns-data</command> creates 
<itemizedlist>
<listitem><para>
an NS record showing <filename><replaceable>x</replaceable>.ns.<replaceable>fqdn</replaceable></filename> as a name server for <replaceable>fqdn</replaceable> and 
</para></listitem>
<listitem><para>
an A or AAAA record showing <replaceable>ip</replaceable> as the IP address of <filename><replaceable>x</replaceable>.ns.<replaceable>fqdn</replaceable></filename>. 
</para></listitem>
</itemizedlist>
</para>
<para>
Normally <code>&#x26;</code> is used for domains delegated by this server to child servers, while <code>.</code> is used for domains delegated by other servers to this server. 
</para>
<para>
You may have several name servers for one domain, with a different <replaceable>x</replaceable> for each server. 
If <replaceable>x</replaceable> contains a dot then it is treated specially; as for <code>.</code> lines and with the same caveat.
</para>
<refsection><title>Examples</title>
<informalexample>
<programlisting>&#x26;serious.panic.example:203.0.113.6:a
&#x26;serious.panic.example:3fff_0_1978_0308_1980_0125_0102_6:a
</programlisting>
<para>
creates an NS record showing <filename>a.ns.serious.panic.example</filename> as a name server for <filename>serious.panic.example</filename>, an A record showing 203.0.113.6 as the IPv4 address of <filename>a.ns.serious.panic.example</filename>, and an AAAA record showing 3fff:0:1978:308:1980:125:102:6 as the IPv6 address of <filename>a.ns.serious.panic.example</filename>. 
</para>
</informalexample>
<informalexample>
<programlisting>&#x26;serious.panic.example:203.0.113.7:ns7.panic.example
&#x26;serious.panic.example:3fff_0_1978_0308_1980_0125_0102_7:ns7.panic.example
</programlisting>
<para>
creates an NS record showing <filename>ns7.panic.example</filename> as a name server for <filename>serious.panic.example</filename>, an A record showing 203.0.113.7 as the IPv4 address of <filename>ns7.panic.example</filename>, and an AAAA record showing 3fff:0:1978:308:1980:125:102:7 as the IPv6 address of <filename>ns7.panic.example</filename>. 
</para>
</informalexample>
</refsection>
</listitem>
</varlistentry>

<varlistentry>
<term>
<programlisting>=<replaceable>fqdn</replaceable>:<replaceable>ip</replaceable>:<replaceable>ttl</replaceable>:<replaceable>timestamp</replaceable>:<replaceable>lo</replaceable>
</programlisting>
</term>
<listitem>
<para>
Host <replaceable>fqdn</replaceable> with IP address <replaceable>ip</replaceable>. 
<command>tinydns-data</command> creates 
<itemizedlist>
<listitem><para>
an A or AAAA record showing <replaceable>ip</replaceable> as the IP address of <replaceable>fqdn</replaceable> and 
</para></listitem>
<listitem><para>
a PTR ("pointer") record showing <replaceable>fqdn</replaceable> as the name of d.c.b.a.in-addr.arpa if ip is a.b.c.d. 
</para></listitem>
</itemizedlist>
</para>
<para>
Remember to specify name servers for some suffix of <replaceable>fqdn</replaceable>; otherwise tinydns will not respond to queries about <replaceable>fqdn</replaceable>. 
The same comment applies to other records described below. 
Similarly, remember to specify name servers for some suffix of <filename><replaceable>d</replaceable>.<replaceable>c</replaceable>.<replaceable>b</replaceable>.<replaceable>a</replaceable>.in-addr.arpa</filename>, if that domain has been delegated to you. 
</para>
<refsection><title>Example</title>
<informalexample>
<programlisting>=dont.panic.example:203.0.113.108
=dont.panic.example:3fff_0_1978_0308_1980_0125_0102_108
</programlisting>
<para>
creates an A record showing 203.0.113.108 as the IPv4 address of <filename>dont.panic.example</filename>, an AAAA record showing 3fff:0:1978:308:1980:125:102:108 as the IPv6 address of <filename>dont.panic.example</filename>, and PTR records showing <filename>dont.panic.example</filename> as the names of <filename>108.113.0.203.in-addr.arpa</filename> and <filename>8.0.1.0.2.0.1.0.5.2.1.0.0.8.9.1.8.0.3.0.8.7.9.1.0.0.0.0.f.f.f.3.ip6.arpa</filename>.
</para>
</informalexample>
</refsection>
</listitem>
</varlistentry>

<varlistentry>
<term>
<programlisting>+<replaceable>fqdn</replaceable>:<replaceable>ip</replaceable>:<replaceable>ttl</replaceable>:<replaceable>timestamp</replaceable>:<replaceable>lo</replaceable>
</programlisting>
</term>
<listitem>
<para>
Server side alias <replaceable>fqdn</replaceable> with IP address <replaceable>ip</replaceable>. 
This is just like <code>=<replaceable>fqdn</replaceable>:<replaceable>ip</replaceable>:<replaceable>ttl</replaceable></code> except that <command>tinydns-data</command> does not create the PTR record. 
</para>
<refsection><title>Example</title>
<informalexample>
<programlisting>+dont.panic.example:203.0.113.109
+dont.panic.example:3fff_0_1978_0308_1980_0125_0102_109
</programlisting>
<para>
creates an A record showing 203.0.113.109 as another IPv4 address for <filename>dont.panic.example</filename>, and an AAAA record showing 3fff:0:1978:308:1980:125:102:109 as another IPv6 address for <filename>dont.panic.example</filename>.
</para>
</informalexample>
</refsection>
</listitem>
</varlistentry>

<varlistentry>
<term>
<programlisting>-<replaceable>fqdn</replaceable>:<replaceable>ip</replaceable>:<replaceable>ttl</replaceable>:<replaceable>timestamp</replaceable>:<replaceable>lo</replaceable>
</programlisting>
</term>
<listitem>
<para>
This type of line is used by programs that automatically edit <code>+</code> lines in data to temporarily exclude addresses of machines whilst leaving the possibility for simply restoring them.
(A machine, or one of its network interfaces, could be temporarily out of service, for example.)
The line is ignored. 
</para>
<refsection><title>Example</title>
<informalexample>
<programlisting>-dont.panic.example:203.0.113.109
+dont.panic.example:3fff_0_1978_0308_1980_0125_0102_109
</programlisting>
<para>
is how the IPv4 address record can be disabled from the <code>+</code> example.
</para>
</informalexample>
</refsection>
</listitem>
</varlistentry>

<varlistentry>
<term>
<programlisting>S<replaceable>fqdn</replaceable>:<replaceable>ip</replaceable>:<replaceable>x</replaceable>:<replaceable>p</replaceable>:<replaceable>prio</replaceable>:<replaceable>wt</replaceable>:<replaceable>ttl</replaceable>:<replaceable>timestamp</replaceable>:<replaceable>lo</replaceable>
</programlisting>
</term>
<listitem>
<para>
Service for <replaceable>fqdn</replaceable>. 
<command>tinydns-data</command> creates 
<itemizedlist>
<listitem><para>
a SRV ("service") record showing <filename><replaceable>x</replaceable>.srv.<replaceable>fqdn</replaceable></filename> as a service for <replaceable>fqdn</replaceable> on port <replaceable>p</replaceable> with priority <replaceable>prio</replaceable> and weight <replaceable>wt</replaceable>, and 
</para></listitem>
<listitem><para>
an A or AAAA record showing <replaceable>ip</replaceable> as the IP address of <filename><replaceable>x</replaceable>.srv.<replaceable>fqdn</replaceable></filename>. 
</para></listitem>
</itemizedlist>
</para>
<para>
You may omit <replaceable>prio</replaceable> and <replaceable>wt</replaceable>; the defaults are 0. 
If <replaceable>x</replaceable> contains a dot then it is treated specially; see above. 
You may create several SRV records for <replaceable>fqdn</replaceable>, with a different <replaceable>x</replaceable> for each server. 
</para>
<note>
The <filename><replaceable>x</replaceable>.srv.<replaceable>fqdn</replaceable></filename> names may seem cumbersome to humans, but the idea of service records is that humans do not see these domain names.
They see a program that (say) speaks SIP over TCP, and only the part of <replaceable>fqdn</replaceable> after the initial underscored labels.
The <filename><replaceable>x</replaceable>.srv</filename> scheme, moreover, has the same compression advantages for DNS/UDP packets as for <code>.</code>, <code>&#x26;</code>, and <code>@</code> lines.
</note>
<refsection><title>Examples</title>
<informalexample>
<programlisting>S_sip._udp.slocombe.example:203.0.113.88:a:5060:10:20
S_sip._udp.slocombe.example:3fff_0_1972_0908_1985_0401_33_88:a:5060:10:20
</programlisting>
<para>
creates a SRV record showing port 5060 of <filename>a.srv._sip._udp.slocombe.example</filename> as a SIP/UDP service for <filename>slocombe.example</filename> with priority 10 and wt 20, an A record showing 203.0.113.88 as the IPv4 address of <filename>a.srv._sip._udp.slocombe.example</filename>, and an AAAA record showing 3fff:0:1972:908:1985:401:33:88 as the IPv6 address of <filename>a.srv._sip._udp.slocombe.example</filename>. 
</para>
</informalexample>
<informalexample>
<programlisting>S_nicname._tcp.humphries.example:203.0.113.65:a:43:10:20
S_nicname._tcp.humphries.example:3fff_0_1972_0908_1985_0401_33_65:a:43:10:20
</programlisting>
<para>
creates a SRV record showing port 43 of <filename>a.srv._nicname._tcp.humphries.example</filename> as a NICNAME/TCP service for <filename>humphries.example</filename> with priority 10 and wt 20, an A record showing 203.0.113.65 as the IPv4 address of <filename>a.srv._nicname._tcp.humphries.example</filename>, and an AAAA record showing 3fff:0:1972:908:1985:401:33:65 as the IPv6 address of <filename>a.srv._nicname._tcp.humphries.example</filename>. 
</para>
</informalexample>
<informalexample>
<programlisting>S_gemini._tcp.brahms.example:203.0.113.45:a:1965:10:20
S_gemini._tcp.brahms.example:3fff_0_1972_0908_1985_0401_33_45:a:1965:10:20
</programlisting>
<para>
creates a SRV record showing port 1965 of <filename>a.srv._gemini._tcp.brahms.example</filename> as a GEMINI/TCP service for <filename>brahms.example</filename> with priority 10 and wt 20, an A record showing 203.0.113.45 as the IPv4 address of <filename>a.srv._gemini._tcp.brahms.example</filename>, and an AAAA record showing 3fff:0:1972:908:1985:401:33:45 as the IPv6 address of <filename>a.srv._gemini._tcp.brahms.example</filename>. 
</para>
</informalexample>
</refsection>
</listitem>
</varlistentry>

<varlistentry>
<term>
<programlisting>H<replaceable>fqdn</replaceable>:<replaceable>ip</replaceable>:<replaceable>x</replaceable>:<replaceable>prio</replaceable>:<replaceable>params</replaceable>:<replaceable>ttl</replaceable>:<replaceable>timestamp</replaceable>:<replaceable>lo</replaceable>
</programlisting>
</term>
<listitem>
<para>
HTTPS service for <replaceable>fqdn</replaceable>. 
<command>tinydns-data</command> creates 
<itemizedlist>
<listitem><para>
an HTTPS ("HTTP/SSL service") record showing <filename><replaceable>x</replaceable>.<replaceable>fqdn</replaceable></filename> as an HTTPS service for <replaceable>fqdn</replaceable> with priority <replaceable>prio</replaceable>, and 
</para></listitem>
<listitem><para>
an A or AAAA record showing <replaceable>ip</replaceable> as the IP address of <filename><replaceable>x</replaceable>.<replaceable>fqdn</replaceable></filename>. 
</para></listitem>
</itemizedlist>
</para>
<note>
<replaceable>params</replaceable> is not currently implemented and must be blank.
</note>
<para>
You may omit <replaceable>prio</replaceable>; the default is 0. 
If <replaceable>x</replaceable> contains a dot then it is treated specially; see above. 
If <replaceable>x</replaceable> is omitted then it defaults to <filename>.</filename>.
You may create several HTTPS records for <replaceable>fqdn</replaceable>, with a different <replaceable>x</replaceable> for each server. 
</para>
<refsection><title>Examples</title>
<informalexample>
<programlisting>Hrumbold.example:203.0.113.88:a:0
Hrumbold.example:3fff_0_1972_0908_1985_0401_33_88:a:0
</programlisting>
<para>
creates an HTTPS record showing <filename>a.rumbold.example</filename> as an HTTPS service for <filename>rumbold.example</filename> with priority 0, an A record showing 203.0.113.88 as the IPv4 address of <filename>a.rumbold.example</filename>, and an AAAA record showing 3fff:0:1972:908:1985:401:33:88 as the IPv6 address of <filename>a.rumbold.example</filename>. 
</para>
</informalexample>
</refsection>
</listitem>
</varlistentry>

<varlistentry>
<term>
<programlisting>@<replaceable>fqdn</replaceable>:<replaceable>ip</replaceable>:<replaceable>x</replaceable>:<replaceable>dist</replaceable>:<replaceable>ttl</replaceable>:<replaceable>timestamp</replaceable>:<replaceable>lo</replaceable>
</programlisting>
</term>
<listitem>
<para>
Mail exchanger for <replaceable>fqdn</replaceable>. 
<command>tinydns-data</command> creates 
<itemizedlist>
<listitem><para>
an MX ("mail exchanger") record showing <filename><replaceable>x</replaceable>.mx.<replaceable>fqdn</replaceable></filename> as a mail exchanger for <replaceable>fqdn</replaceable> at distance <replaceable>dist</replaceable> and 
</para></listitem>
<listitem><para>
an A or AAAA record showing <replaceable>ip</replaceable> as the IP address of <filename><replaceable>x</replaceable>.mx.<replaceable>fqdn</replaceable></filename>. 
</para></listitem>
</itemizedlist>
</para>
<para>
You may omit <replaceable>dist</replaceable>; the default distance is 0. 
If <replaceable>x</replaceable> contains a dot then it is treated specially; see above. 
You may create several MX records for <replaceable>fqdn</replaceable>, with a different <replaceable>x</replaceable> for each server. 
Make sure to arrange for the SMTP server on each IP address to accept mail for <replaceable>fqdn</replaceable>. 
</para>
<refsection><title>Example</title>
<informalexample>
<programlisting>@panic.example:203.0.113.88:a
@panic.example:3fff_0_1978_0308_1980_0125_0102_88:a
</programlisting>
<para>
creates an MX record showing <filename>a.mx.panic.example</filename> as a mail exchanger for <filename>panic.example</filename> at distance 0, an A record showing 203.0.113.88 as the IP address of <filename>a.mx.panic.example</filename>, and an AAAA record showing 3fff:0:1978:308:1980:125:102:88 as the IP address of <filename>a.mx.panic.example</filename>. 
</para>
</informalexample>
</refsection>
</listitem>
</varlistentry>

<varlistentry>
<term>
<programlisting>'<replaceable>fqdn</replaceable>:<replaceable>s</replaceable>:<replaceable>ttl</replaceable>:<replaceable>timestamp</replaceable>:<replaceable>lo</replaceable>
</programlisting>
</term>
<listitem>
<para>
TXT ("text") record for <replaceable>fqdn</replaceable>. 
<command>tinydns-data</command> creates 
</para>
<itemizedlist>
<listitem><para>
a TXT record for <replaceable>fqdn</replaceable> containing the string <replaceable>s</replaceable>. 
</para></listitem>
</itemizedlist>
<para>
You may use octal \nnn codes to include arbitrary bytes inside <replaceable>s</replaceable>; for example, \072 is a colon. 
</para>
</listitem>
</varlistentry>

<varlistentry>
<term>
<programlisting>^<replaceable>fqdn</replaceable>:<replaceable>p</replaceable>:<replaceable>ttl</replaceable>:<replaceable>timestamp</replaceable>:<replaceable>lo</replaceable>
</programlisting>
</term>
<listitem>
<para>
PTR record for <replaceable>fqdn</replaceable>. 
<command>tinydns-data</command> creates 
<itemizedlist>
<listitem><para>
a PTR record for <replaceable>fqdn</replaceable> pointing to the domain name <replaceable>p</replaceable>. 
</para></listitem>
</itemizedlist>
</para>
<para>
Usually a <code>=</code> line is a more convenient way to create a mapping from an IP address to a domain name.
</para>
</listitem>
</varlistentry>

<varlistentry>
<term>
<programlisting>C<replaceable>fqdn</replaceable>:<replaceable>p</replaceable>:<replaceable>ttl</replaceable>:<replaceable>timestamp</replaceable>:<replaceable>lo</replaceable>
</programlisting>
</term>
<listitem>
<para>
Client side alias <replaceable>fqdn</replaceable> with target <replaceable>p</replaceable>. 
<command>tinydns-data</command> creates 
<itemizedlist>
<listitem><para>
a CNAME record for <replaceable>fqdn</replaceable> pointing to the domain name <replaceable>p</replaceable>. 
</para></listitem>
</itemizedlist>
</para>
<caution>
Don't use <code>C<replaceable>fqdn</replaceable></code> if there are any other records for <replaceable>fqdn</replaceable>.
The DNS protocol does not handle this.
Don't use <code>C<replaceable>fqdn</replaceable></code> for straightforward simple aliases all mapping <replaceable>fqdn</replaceable>s to a common IP address; use <code>+<replaceable>fqdn</replaceable></code> instead.
The latter is a lot more efficient, as it is handled DNS server-side rather than DNS client-side.
Remember the wise words of Inigo Montoya: "You keep using CNAME records. I do not think they mean what you think they mean." 
</caution>
</listitem>
</varlistentry>

<varlistentry>
<term>
<programlisting>Z<replaceable>fqdn</replaceable>:<replaceable>mname</replaceable>:<replaceable>rname</replaceable>:<replaceable>ser</replaceable>:<replaceable>ref</replaceable>:<replaceable>ret</replaceable>:<replaceable>exp</replaceable>:<replaceable>min</replaceable>:<replaceable>ttl</replaceable>:<replaceable>timestamp</replaceable>:<replaceable>lo</replaceable>
</programlisting>
</term>
<listitem>
<para>
SOA record for <replaceable>fqdn</replaceable> showing <replaceable>mname</replaceable> as the primary name server, <replaceable>rname</replaceable> (with the first . converted to @) as the contact address, <replaceable>ser</replaceable> as the serial number, <replaceable>ref</replaceable> as the refresh time, <replaceable>ret</replaceable> as the retry time, <replaceable>exp</replaceable> as the expire time, and <replaceable>min</replaceable> as the minimum time. 
</para>
<para>
<replaceable>ser</replaceable>, <replaceable>ref</replaceable>, <replaceable>ret</replaceable>, <replaceable>exp</replaceable>, and <replaceable>min</replaceable> may be omitted; they default to, respectively, the modification time of the data file, 16384 seconds, 2048 seconds, 1048576 seconds, and 2560 seconds. 
</para>
<para>
Usually a . line is a more convenient way to create SOA records.
</para>
</listitem>
</varlistentry>

<varlistentry>
<term>
<programlisting>:<replaceable>fqdn</replaceable>:<replaceable>n</replaceable>:<replaceable>rdata</replaceable>:<replaceable>ttl</replaceable>:<replaceable>timestamp</replaceable>:<replaceable>lo</replaceable>
</programlisting>
</term>
<listitem>
<para>
Generic record for <replaceable>fqdn</replaceable>. 
<command>tinydns-data</command> creates 
<itemizedlist>
<listitem><para>
a record of type <replaceable>n</replaceable> for <replaceable>fqdn</replaceable> showing <replaceable>rdata</replaceable>. 
</para></listitem>
</itemizedlist>
</para>
<para>
<replaceable>n</replaceable> must be an integer between 1 and 65535; it must not be 2 (NS), 5 (CNAME), 6 (SOA), 12 (PTR), 15 (MX), 251 (IXFR), 252 (AXFR) or 255 (ANY). 
The proper format of <replaceable>rdata</replaceable> depends on <replaceable>n</replaceable>. 
You may use octal \nnn codes to include arbitrary bytes inside <replaceable>rdata</replaceable>.
</para>
</listitem>
</varlistentry>

</variablelist>

</refsection>

</refsection>

<refsection>
<title>Example</title>

<informalexample>
<para>
A typical data file:
</para>
<programlisting>.heaven.af.example:203.0.113.5:a
.heaven.af.example:203.0.113.6:b
.heaven.af.example:3fff_0_4ab1_7_eb53_6820_90_5:a
.heaven.af.example:3fff_0_4ab1_7_eb53_6820_90_6:b
# per support contract, renewable annually -- jim
.heaven.af.example:3fff_0_8_716d_bac8_92_322_53:a.ns.offsite.example.com

.113.0.203.in-addr.arpa:203.0.113.5:a
.113.0.203.in-addr.arpa:203.0.113.6:b
.0.f.f.f.3.ip6.arpa:3fff_0_4ab1_7_eb53_6820_90_5:a
.0.f.f.f.3.ip6.arpa:3fff_0_4ab1_7_eb53_6820_90_6:b

@heaven.af.example:203.0.113.4:a:10
@heaven.af.example::offsite.example.com:20

=lion.heaven.af.example:203.0.113.4
+lion.heaven.af.example:3fff_0_4ab1_7_eb53_6820_90_4:b
=tiger.heaven.af.example:3fff_0_4ab1_7_eb53_6820_90_5:b
+tiger.heaven.af.example:203.0.113.5
=bear.heaven.af.example:203.0.113.6
+bear.heaven.af.example:3fff_0_4ab1_7_eb53_6820_90_6:b
# cheetah's IPv6 is wonky -- jim
=cheetah.heaven.af.example:203.0.113.248
-cheetah.heaven.af.example:3fff_0_4ab1_7_eb53_6820_90_248:b
# experiment with IPv6-only for panther -- jim
=panther.heaven.af.example:3fff_0_4ab1_7_eb53_6820_90_249:b
-panther.heaven.af.example:203.0.113.249</programlisting>
</informalexample>

</refsection>

<refsection>
<title>History</title>
<para>
<command>tinydns-data</command> was originally part of <personname><firstname>Daniel</firstname> <othername>J.</othername> <surname>Bernstein</surname></personname>'s djbdns toolset in 2000.
</para>
<para>
<command>tinydns-data</command> ceased using the <filename>ip6.int.</filename> superdomain in 2016.
The <filename>ip6.int.</filename> superdomain was deprecated by RFC3152 in 2001 and obsoleted by RFC4159 in 2005.
</para>
</refsection>

<refsection>
<title>Author</title>
<para>
Original code and documentation by <personname><firstname>Daniel</firstname> <othername>J.</othername> <surname>Bernstein</surname></personname>.
Documentation modernizations by <personname><firstname>Jonathan</firstname> <surname>de Boyne Pollard</surname></personname>.
</para>
</refsection>

</refentry>
