Traditional DNS Howto - Page 3
The Primary Zone FileNow let's look at the zone file for the centralsoft domain: pri.centralsoft.org:
SOA refers to "Start of Authority". When you look at Figure 1, remember that DNS distributes its database. By the time you enter the picture, the system has handed off authority for part of the entire database to you. So, your zone file has to indicate where your authority starts. Your authority starts in your zone file. Your Top Level Domain servers are waiting for you to do your part of the job.
The data field of the SOA record contains several components or fields. You need to provide data or answers in the record which will allow another server on the Internet to satisfy its query. Think of the data field as a computer RECORD which has several fields. They include:
The root name of the zone. The "@" sign is a shorthand reference to the current origin (zone) in the /etc/named.conf file for that particular database file. The host name of the master server for this zone is server1.centralsoft.org. Don't worry if this jargon doesn't make sense. If just means that back in the named.conf configuration file an entry points to this file and this file points back to the entry in the configuration file.
A number of different DNS classes exist. For our purposes we will use the IN or Internet class used when defining IP address mapping information for BIND. The other classes exist for non Internet protocols and functions.
The type of DNS resource record. In the example, this is an SOA resource record.
Fully qualified name of your primary name server. Must be followed by a period.
This is the email address of the person responsible for the domain. Notice that instead of an @ sign, the address uses a period and is followed by a period. In this case, the email address is the root user or root.loalhost. In other applications the email address would be [email protected]
A serial number for the current configuration is usually in a date format YYYYMMDD with an incremented double digit number tagged to the end. This allows you to do multiple edits each day with a serial number that both increments and reflects the date on which the change was made. It's a numeric value that the slave server can use to check whether the zone file has been updated. The slave periodically checks the serial number to see if it has changed. If it has, the slave will perform a zone transfer. 2006012103 is the serial number in the zone file above.
This field tells a slave DNS server how often it should check the master. This field represents a length in seconds. Every refresh cycle, the slave server checks to see whether it needs to perform a zone transfer. In this file we use 28800 as the value.
This field tells the slave how often it should try to connect to the master in the event of a connection failure. The interval in our example is 7200.
Total amount of time a slave should retry to contact the master before expiring the data it contains. Future references will be directed towards the root servers. This is the expiration time, the length of time that the slave server should continue to respond to queries even if it cannot update the zone file. An expiration period exists under the theory that out of date data is worse than no data at all. In our example we use 604800.
This is the default time to live (TTL) for this domain in seconds. Times will occur when remote clients will make queries for sub-domains that don't exist in your records. If so configured, your DNS server will respond with a no domain or NXDOMAIN response that the client's remote server caches. The TTL value defines the caching duration your DNS response. The value is included in your server's response. Any resource record that does not have a specified TTL uses this default. Because 86400 seconds is one day, the querying cache's record should die in one day.
The next database record type specifies the name servers for the domain. NS stands for name server. You already know that server1.centralsoft.org represents the host name of the primary domain server. The secondary or slave server for this domain follows. ns0.centralsoft.org is the hostname of the secondary name server for this domain.
Following the name servers you will see the MX record type which identifies the mail server for the domain. Following the mail record you can see the A record type which maps a name to an IP address. In the file above we have four A records which map the host names to IP addresses.
Let's write a zone file. You should name it for your own domain. Mine is pri.centralsoft.org. Name your zone file for your domain.The first line in our zone file looks like this:
The "@" sign in the line refers to the "origin" for this zone file which is server1.centralsoft.org. DNS uses this as simply a label to designate the Start Of Authority (SOA) record that appears at the beginning of any zone file defining a domain. Don't make too much out of this. If you read much about DNS, then you will see people using this strange term "current origin". Few people explain what that means. It's just another bit of jargon.
The next item on the line "IN" stands for Internet. People call this a class field. Three classes exist including "HS" for Hesiod servers and "CH" which stands for Chaosnet servers. You will only see Internet servers, so don't sweat the small stuff.
IETF RFC 1035, Domain Names - Implementation and Specification says:
The SOA record stores information about the name of the server that supplied the data for the zone; the administrator of the zone; the current version of the data file [serial number]; the number of seconds a secondary name server should wait before checking for updates; the number of seconds a secondary name server should wait before retrying a failed zone transfer; the maximum number of seconds that a secondary name server can use data before it must either be refreshed or expire; and a default number of seconds for the time-to-live file on resource records.
What's next? The mailing address of the administrator in this file is [email protected] Obviously, my mail server delivers local mail so messages related to this process will go to root's mailbox.
In case you missed it, the first line is only part of the SOA record. It has additional fields. Notice the "(" at the end of the line. Here's the rest of the record.
The serial number is the only field in the record that does not refer to seconds. You designate the serial number as a numeric value so when a slave server checks to the zone file on the primary server if will know if the zone file changed. The slave can then do a zone transfer and populate its database with the current records.
The remaining fields use seconds to denote their values. For example, the number of seconds a secondary name server should wait before checking for updates is in the refresh record. 28800 seconds is 480 minutes or 8 hours.
Also notice that the SOA record ends at the end of the Minimum-Time to Live (TTL). You can see the ")" symbol which closes the record values.