Real Programmers/ How It Works/ DNS/ Overview
Google site:

realprogrammers.com

DNS Overview

The domain name system provides a way to find an address from a domain name. It does this by holding a database of records which map names to various types of addresses:
A record
When most people think of DNS, this is the information they're thinking of: the address www.realprogrammers.com has an A record containing an IP address, say, 64.125.127.90. A web browser can look for an A record, be told an IP address and from that it can attempt to connect to it.
MX record
MX stands for Mail eXchange and is used to find mail servers that will accept mail for delivery (as opposed to mail servers from which to retrieve mail). In addition to an IP address, the MX record contains a priority ranking which lists the order in which to attempt to deliver mail: thus you effectively have primary, secondary, tertiary, etc mail servers. If the primary isn't contactable, try the secondary, etc. If the secondary accepts, it'll try to deliver to the primary later.
NS record
A Name Server record is queried to find out where to which other domain name servers to query deeper into a domain. To understand this requires some more in-depth knowledge of the hierarchy of the DNS which we'll defer for later.
SOA record
Start Of Authority contains some parameters about the domain itself, like a form of timestamp for its last update (serial number), a contact email address, and a collection of more abstruse data. This data is used primarily by the name servers & their software about how to answer requests, cache information and transfer domain data between each other. It is for the most part entirely possible to completely ignore the SOA as an end-user so we won't discuss it further.

Examples of querying the DNS

Here we're using the host command. Many are familiar with nslookup however this program has been deprecated in favor of host and dig, which we'll see shortly.

A record

$ host www.realprogrammers.com
www.realprogrammers.com A       64.125.129.70
$
Nothing too surprising there.

MX record

$ host -t mx yahoo.com
yahoo.com               MX      5 mx4.mail.yahoo.com
yahoo.com               MX      1 mx1.mail.yahoo.com
yahoo.com               MX      1 mx2.mail.yahoo.com
$
We see that yahoo.com has apparently three mail servers of which two are considered primary since they have the higher (numerically lower) priority. Now, in order to actually deliver the mail, the delivering server still needs to know the IP address of that server, in other words it has to lookup an A record.

However, upon closer inspection of one such A record we discover,

$ host mx1.mail.yahoo.com
mx1.mail.yahoo.com      A       64.157.4.81
mx1.mail.yahoo.com      A       64.157.4.85
mx1.mail.yahoo.com      A       64.157.4.89
$

Round Robin DNS

mx1.mail.yahoo.com has three IP addresses! So yahoo.com has many more than three possible destinations for its mail. How does it choose? The name server being asked for the IP addresses returns a single address for each query, one after the other. Once it has returned the last of its collection it starts at the beginning again. This is referred to as round robin DNS, and can be used as a simple way to distribute access to a number of servers. Round Robin can as equally be used for webservers as mail servers, or any job where spreading connections across multiple addresses may be useful.

NS record

Any one of the following servers will answer queries for any name within the realprogrammers.com domain:
$ host -t ns realprogrammers.com
realprogrammers.com     NS      ns1.granitecanyon.com
realprogrammers.com     NS      ns2.granitecanyon.com
realprogrammers.com     NS      ns2.realprogrammers.com
realprogrammers.com     NS      ns3.realprogrammers.com
realprogrammers.com     NS      ns5.realprogrammers.com
realprogrammers.com     NS      ns0.realprogrammers.com
$
Again, like an MX record, a further A record query is required to find the actual IP address, or indeed addresses. NS records are also returned to querying clients in a round robin fashion.

SOA record

Just for completeness and curiosity's sake here is an SOA record,
$ host -t soa paulm.com
paulm.com               SOA     tantrix.realprogrammers.com
hostmaster.realprogrammers.com (
                   2002021203   ;serial (version)
                   10800        ;refresh period (3 hours)
                   3600 ;retry interval (1 hour)
                   604800       ;expire time (1 week)
                   86400        ;default ttl (1 day)
                   )
$
The paulm.com domain we learn lives on tantrix.realprogrammers.com, the contact address is hostmaster@realprogrammers.com, and well, a bunch of other stuff :-)

All non-user content and code Copyright © 2000-2006 realprogrammers.com / Paul Makepeace. Comments & feedback welcome!