Database
********

The default database name is mydns.

To specify a different name, edit the database variable in your mydns.conf.

You can freely add columns to the mydns database.  You can also modify the columns that MyDNS uses, as long as you don't change their names.

The table layouts described here are for the tables created on a MySQL database.  If you're using PostgreSQL, the fields are pretty much the same; however, the field types are slightly different.  You can run mydns --create-tables to see the exact table structures.

The soa table
=============

The soa table contains one row for each zone for which the server is authoritative.

The default values for the various timer fields are from RFC 1537 (http://www.ietf.org/rfc/rfc1537.txt).

id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY (MySQL)

id SERIAL NOT NULL PRIMARY KEY (PostgreSQL)
     A unique number identifying this zone.

origin CHAR(255) NOT NULL (MySQL)

origin VARCHAR(255) NOT NULL (PostgreSQL)
     The name of this zone.  (Unique key)

     ex: example.com.

ns CHAR(255) NOT NULL (MySQL)

ns VARCHAR(255) NOT NULL (PostgreSQL)
     The name of the name server that was the original or primary source of data for this zone.  (meaningless to MyDNS)

     ex: primary.example.com.

mbox CHAR(255) NOT NULL (MySQL)

mbox VARCHAR(255) NOT NULL (PostgreSQL)
     A name which specifies the mailbox of the person responsible for this zone. This should be specified in the mailbox-as-domain-name format where the @ character is replaced with a dot.  (meaningless to MyDNS)

     ex: postmaster.example.com.

serial INT UNSIGNED NOT NULL DEFAULT '1' (MySQL)

serial INTEGER NOT NULL DEFAULT 1 (PostgreSQL)
     A "version number" for this zone.  DNS servers that rely on AXFR for zone transfers use this to determine when updates have occurred.  Popular values to use are the Unix timestamp or a date in the form YYYYMMDD.  (see Zone transfers).

     ex: 20020529

refresh INT UNSIGNED NOT NULL DEFAULT '28800' (MySQL)

refresh INTEGER NOT NULL DEFAULT 28800 (PostgreSQL)
     The number of seconds after which slave nameservers should check to see if this zone has been changed.  If the zone's serial number has changed, the slave nameserver initiates a zone transfer. (meaningless to MyDNS)

     ex: 10800

retry INT UNSIGNED NOT NULL DEFAULT '7200' (MySQL)

retry INTEGER NOT NULL DEFAULT 7200 (PostgreSQL)
     This specifies the number of seconds a slave nameserver should wait before retrying if it attmepts to transfer this zone but fails. (meaningless to MyDNS)

     ex: 3600

expire INT UNSIGNED NOT NULL DEFAULT '604800' (MySQL)

expire INTEGER NOT NULL DEFAULT 604800 (PostgreSQL)
     If for expire seconds the primary server cannot be reached, all information about the zone is invalidated on the secondary servers (i.e., they are no longer authoritative for that zone). (meaningless to MyDNS)

     ex: 60400

minimum INT UNSIGNED NOT NULL DEFAULT '86400' (MySQL)

minimum INTEGER NOT NULL DEFAULT 86400 (PostgreSQL)
     The minimum TTL field that should be exported with any RR from this zone.  If any RR in the database has a lower TTL, this TTL is sent instead.

     ex: 86400

ttl INT UNSIGNED NOT NULL DEFAULT '86400' (MySQL)

ttl INTEGER NOT NULL DEFAULT 86400 (PostgreSQL)
     The number of seconds that this zone may be cached before the source of the information should again be consulted.  Zero values are interpreted to mean that the zone should not be cached.

     ex: 86400

The rr table
============

The rr table contains all non-SOA resource record types.

It has a unique key on the combination of zone, name, type, and data.

id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY (MySQL)

id SERIAL NOT NULL PRIMARY KEY (PostgreSQL)
     A unique number identifying this record.

zone INT UNSIGNED NOT NULL (MySQL)

zone INTEGER NOT NULL (PostgreSQL)
     The ID of the zone (from the soa table) to which this resource record belongs.  (see soa table).

     For PostgreSQL databases, this column is also created with FOREIGN KEY (zone) REFERENCES soa (id) ON DELETE CASCADE.

name CHAR(64) NOT NULL (MySQL)

name VARCHAR(64) NOT NULL (PostgreSQL)
     The name that this RR describes.  Wildcard values such as * or *.sub are supported, and this field can contain a FQDN or just a hostname.  It may contain out-of-zone data if this is a glue record.

     ex: foo

     ex: foo.example.com.

type ENUM('A','AAAA','CNAME','HINFO','MX','NAPTR','NS','PTR','RP','SRV','TXT') NOT NULL (MySQL)

type VARCHAR(5) NOT NULL CHECK (type='A' OR type='AAAA' OR type='CNAME' OR type='HINFO' OR type='MX' OR type='NAPTR' OR type='NS' OR type='PTR' OR type='RP' OR type='SRV' OR type='TXT') (PostgreSQL)
     The type of resource record.  (see Supported RR types).

data CHAR(128) NOT NULL (MySQL)

data VARCHAR(128) NOT NULL (PostgreSQL)
     The data associated with this resource record.  See Supported RR types, for specifications and examples of the type of data each record type should contain.

aux INT UNSIGNED NOT NULL (MySQL)

aux INTEGER NOT NULL default 0 (PostgreSQL)
     An auxillary numeric value in addition to data.  For MX records, this field specifies the preference.  For SRV records, this field specifies the priority.

ttl INT UNSIGNED NOT NULL DEFAULT '86400' (MySQL)

ttl INTEGER NOT NULL default 86400 (PostgreSQL)
     The time interval that this resource record may be cached before the source of the information should again be consulted.  Zero values are interpreted to mean that the RR can only be used for the transaction in progress, and should not be cached.

Supported RR types
==================

The type column in the rr table may contain any of the following supported resource record types:

A
     A host address.  The data column should contain the IP address (in numbers-and-dots format) associated with the name.

     example: 192.168.1.88

AAAA
     An IPv6 host address.  The data column should contain the IPv6 address associated with the name.

     example: 3ffe:b00:c18:3::a

ALIAS
     A server side alias.  An alias is like a CNAME, only it is handled entirely by the server.  The data column should contain the hostname aliased by name.  Aliases can be used in place of A records.  The client will only see A records and will not be able to tell that aliases are involved. The hostname specified by data must exist in the database.

     It can be useful to use aliases for everything.  Use A records for the canonical name of the machine and use aliases for any additional names. This is especially useful when combined with automatic PTR records.  If a single IP address is only used for one A record, then there will never be any confusion over what the PTR record should be.

     In order for server-side aliases to work, MyDNS must have been compiled with configure --enable-alias.

     example: albuquerque.example.com. (FQDN)

     example: albuquerque (hostname only)

CNAME
     The canonical name for an alias.  The data column should contain the real name of the machine specified by name.  data may be a hostname or an FQDN.

     example: porcini.example.com. (FQDN)

     example: porcini (hostname only)

HINFO
     Host information.  The data column should contain two strings which provide information about the host specified by name.  The first string specifies the CPU type, and the second string describes the operating system type.  The two strings should be separated by a space.  If either string needs to contain a space, enclose it in quotation marks.

     Well-known CPU and operating system types that are most often used are listed in RFC 1700 (http://www.ietf.org/rfc/rfc1700.txt).

     example: "Pentium Pro" Linux

MX
     Mail exchange.  The data column should contain the hostname or FQDN of a mail server which will accept mail for the host specified by name.  The aux column should contain a preference for this mail server.  Mail transfer agents prefer MX records with lower values in aux.

     example: ns0.example.com. (FQDN)

     example: ns0 (hostname only)

NAPTR
     Naming authority pointer.  The data column should contain six fields, separated by whitespace, which describe a regular expression based rewrite rule as described in RFC 2915 (http://www.ietf.org/rfc/rfc2915.txt) for the name specified by name.  The first field is the order (a number) in which the record must be processed with other similar records.  The second field is the preference (a number) in which similar records with equal order values should be processed.  The third field (a string) describe processing flags used while rewriting.  The fourth field (a string) specifies the services available down this rewrite path.  The fifth field (a string) contains a regular expression to use while rewriting. The last field (a string) contains the next name to query along the rewrite path.  If a string contains spaces, it may be enclosed in quotation marks.  If a string needs to contain a literal quotation mark, precede it with a backslash character.

     example: 100 90 "" "" "!http://([^/:]+)!\1!i" .

NS
     An authoritative nameserver.  The data column should contain the hostname or FQDN of a server which should be considered authoritative for the zone listed in name.

     example: france.example.com. (FQDN)

     example: france (hostname only)

PTR
     A domain name pointer.  These records, used only with IN-ADDR.ARPA zones, should contain the canonical hostname of the machine referred to by name in data.

     example: webserver.example.com.

RP
     A responsible person.  The data column should contain the DNS-encoded email address of the person responsible for the name requested, then a space, then a hostname that should return a TXT record containing additional information about the responsible person.  If there is no such TXT record, the second value should contain a dot (.).

     For more information, see RFC 1183 (http://www.ietf.org/rfc/rfc1183.txt).

     example: webmaster.example.com. contactinfo.example.com.

SRV
     Server location.  Specifies the location of the server(s) for a specific protocol and domain.  The data column must contain three space-separated values.  The first value is a number specifying the weight for this entry.  The second field is a number specifying the port on the target host of this service.  The last field is a name specifying the target host.  The aux column should contain the priority of this target host.  Targets with a lower priority are preferred.

     For well-known services, a reserved universal symbolic name may be listed in RFC 1700 (http://www.ietf.org/rfc/rfc1700.txt).

     For more information, see RFC 2782 (http://www.ietf.org/rfc/rfc2782.txt).

     example: 0 9 server.example.com. (FQDN)

     example: 0 9 server (hostname only)

TXT
     A text string.  The data column contains a text string that is returned only when a TXT query is issued for the host specified by name.

     example: This is a string.

Optional columns
================

Each of these columns is optional.

If these columns exist, MyDNS will notice this and enable additional code specific to each optional field.

If you add any of these fields to your database, you must signal MyDNS to rescan the tables by sending it a SIGHUP signal (see Signals).

any.active
----------

Both the soa table and the rr table may contain a column called active.

If this column exists, it should contain a boolean value.  This could be 0/1 (an integer), 'Y'/'N', '1'/'0', or 'Active'/'Inactive'.  For MySQL databases, an ENUM value is recommended.

If the active column is present, whenever records are retrieved from that table, the active column will be honored.  If the row is inactive, it will be as if the row did not exist at all.

To create an active column on your soa table, for example, you might issue SQL statements like this:

MySQL:

     mysql> ALTER TABLE mydns.soa ADD COLUMN active ENUM('Y','N') NOT NULL;
     mysql> ALTER TABLE mydns.soa ADD INDEX (active);

PostgreSQL:

     mydns=# ALTER TABLE soa ADD COLUMN active INT;
     mydns=# UPDATE soa SET active=1;
     mydns=# ALTER TABLE soa ALTER COLUMN active SET NOT NULL;
     mydns=# ALTER TABLE soa ALTER COLUMN active SET DEFAULT 1;

soa.xfer
--------

If the soa table contains a column named xfer and DNS-based zone transfers are enabled (see Zone transfers), the xfer column will be examined whenever a DNS-based zone transfer request is received.

The xfer column should contain one or more IP addresses separated by commas.  These IP addresses will be allowed to transfer the zone.

If the xfer column is empty, no DNS-based zone transfers will be allowed for that zone.

The IP addresses in xfer may contain standard wildcard characters.  Thus, if you want to grant zone transfer access for a particular zone to any IP address, you would set xfer to *.

Addresses may also be specified in CIDR notation (i.e. 192.168.1.1/24) or in network/netmask notation (i.e. 192.168.1.1/255.255.0.0).

The xfer column may be any size you want, and whatever size you think will be adequate for the IP address lists you intend to use.

To create an xfer column on your soa table, for example, you might issue SQL statements like this:

MySQL:

     mysql> ALTER TABLE mydns.soa ADD COLUMN xfer CHAR(255) NOT NULL;

PostgreSQL:

     mydns=# ALTER TABLE soa ADD COLUMN xfer VARCHAR(255);
     mydns=# UPDATE soa SET xfer='';
     mydns=# ALTER TABLE soa ALTER COLUMN xfer SET NOT NULL;
     mydns=# ALTER TABLE soa ALTER COLUMN xfer SET DEFAULT '';

soa.update_acl
--------------

If the soa table contains a column named update_acl and dynamic DNS updates are enabled (see DNS UPDATE), the update column will be examined whenever a DNS UPDATE request is received.

The update_acl column should contain one or more IP addresses separated by commas.  These IP addresses will be allowed to update the zone.

If the update_acl column is empty, no dynamic DNS updates will be allowed for that zone.

The IP addresses in update_acl may contain standard wildcard characters.  Thus, if you want to grant access for a particular zone to any IP address, you would set update_acl to *.

Addresses may also be specified in CIDR notation (i.e. 192.168.1.1/24) or in network/netmask notation (i.e. 192.168.1.1/255.255.0.0).

The update_acl column may be any size you want, and whatever size you think will be adequate for the IP address lists you intend to use.

To create an update_acl column on your soa table, for example, you might issue SQL statements like this:

MySQL:

     mysql> ALTER TABLE mydns.soa ADD COLUMN update_acl CHAR(255) NOT NULL;

PostgreSQL:

     mydns=# ALTER TABLE soa ADD COLUMN update_acl VARCHAR(255);
     mydns=# UPDATE soa SET update_acl='';
     mydns=# ALTER TABLE soa ALTER COLUMN update_acl SET NOT NULL;
     mydns=# ALTER TABLE soa ALTER COLUMN update_acl SET DEFAULT '';