Name resolution only works if records exist in your domain for your hosts and services. This tutorial focuses on adding new records to an existing forward lookup domain.
Types of Records
There are a large number of record types that can be used in DNS. The most popular of which are ‘A’ records, MX records, NS records, and CNAME records. But what exactly are these records and how do we use them? The table below describes some of them.
|A||This is an address record, also known as a hostname record. This record is used to assign a name to an IP address.|
|MX||Mail eXchange records are used to define the mail servers for a domain. There used by other mail servers to know how to send e-mail to recipients in the domain.|
|NS||Name Server records define the name servers for a domain. This points to fully-qualified domain names of the DNS servers for a domain, and rely on glue records to associate the names with IP addresses. Glue records are just A records that other records, like NS records, rely on.|
|CNAME||These records create aliases for A records.|
|SRV||Service records are used for locating services on a network. Active Directory uses these to register records used by clients to allow them to find domain controllers in their site, for example.|
|TXT||Used to add additional information to other records. Some DHCP servers register them to a host they grant an IP address to.|
Absolute and Relative Hostnames
The hostname values of records can either be absolute or relative. Absolute names may or may not belong to the zone the record is created in. Relative hostnames, on the other hand, a relative to the domain defined in the zone the record resides in. In DNS, all fully-qualified names end with a period (.). This may be a new concept to you as most browsers and other Internet apps hide it.
In a zone for serverlab.intra., the following records will resolve to two different places.
web01. IN A 192.168.1.20
The fully qualified name of the record above is actually web01. It will not resolve to web01.serverlab.intra. Here’s another example of an absolute hostname. Even though we are in the serverlab.intra zone, the hostname actually resolves as web01.contoso.com.
web01.contoso.com. IN A 192.168.1.20
web01 IN A 192.168.1.20
This record, unlike the one above, will resolve as web01.serverlab.intra. Another example, seen below, registers the server in a sub-domain.
web01.corp IN A 192.168.1.20
The example above resolves as web01.corp.serverlab.intra.
Adding Records to a Domain
By adding a record into the domain we are registering it. Each record type has options that must be set for the registration to be valid. Take an A record, for example. The requirements for this type are a hostname and an IP address. An MX record on the other hand requires a glue record, the name of the domain, and some priorities and weight values.
This section will show you how to add the different record types to your domain. To add the records, we need to open the zone file for our domain into a text editor. The default location of a zone file on a CentOS 6 server with Bind installed from the default Yum repository is /var/named.
Rember to place your records after the SOA record near the top.
Address records only require two values: a hostname and an IP address. The following assigns the name server01 to IP address 192.168.1.55.
server01 A 192.168.1.55
A mail exchange record requires certain values to be set. The table below lists these values. An MX record also requires an A record for the hostname of the mail server specified.
|Domain||required||Defines the e-mail domain the mail delivery agent (MDA) server|
|TTL||optional>||Sets the time-to-live value of the record for caching purposes. If value isn’t set, the default TTL of the domain of zone will be used.|
|Priority||required||Priorities are used to balance the load between your mail servers. The lower the number, the higher the priority the server will have to receive mail requests.|
|hostname||hostname||The fully qualified name of the mail server. An A record for the mail server must exist.|
- Assign a mail server to the zone’s domain. The @ character is an alias for the fully-qualified domain name of the zone’s domain.
@ MX 10 mail01.serverlab.intra.
- Assign a mail server to the zone’s domain. The space is aliased to the fully-qualified domain name of the zone.
MX 10 mail01.serverlab.intra.
- Assign a mail server to a domain called serverlab.intra.
serverlab.intra. MX 10 mail01.serverlab.intra.
- Assign two mail servers to a domain called serverlab.intra.
serverlab.intra. MX 10 mail01.serverlab.intra. serverlab.intra. MX 20 mail02.serverlab.intra.
A name server record requires certain values to be set. The table below lists these values. Along with the NS record, an A record for the hostname of the name server specified is required. Remember to register both.
|Domain Name||required||Defines the fully-qualified name of the domain the name server is authoritative of.|
|TTL||optional||Sets the time-to-live value of the record for caching purposes. If the value isn’t set, the default TTL of the domain of zone will be used.|
|Name Server hostname||required||The fully qualified name of the mail server. An A record for the mail server must exist.|
- Assign a name server to the zone’s domain. The @ character is an alias for the fully-qualified domain name of the zone’s domain.
@ NS ns01.serverlab.intra.
- Assign a name server to the zone’s domain. The space is aliased to the fully-qualified domain name of the zone.
- Assign a name server to a domain called serverlab.intra.
serverlab.intra. NS ns01.serverlab.intra.
- Assign two name servers to a domain called serverlab.intra.
serverlab.intra. NS ns01.serverlab.intra. serverlab.intra. NS ns02.serverlab.intra.
Reload DNS Zone
Your records are now registered, but your clients will still not be able to resolve them. Bind won’t know about them until the zone file is re-loaded into memory. There are two ways of accomplishing this. The first way is to restart the Bind daemon, which will cause a short outage. The second, and most preferred way, is to simply just reload the zone file. Reloading doesn’t cause any outages.
- Reload the zone file
service bind reload
Adding records to your zone is fairly simplistic. The most important thing to remember while doing so is knowing when or if to use absolute or relative hostnames for your records. A lot of name resolution failures are due to making the simple mistake of using the wrong one.
Tutorials in this Series
- How to Deploy a CentOS 6 BIND DNS Server
- How to Add Forward Lookup Zones to Bind
- Register DNS Records into a Bind Domain
- How to Add Reverse Lookup Zones to Bind
- How to Configure Logging in Bind