|
DNS Primer
In the early days of the Internet, humans and other
computers located the few massive inter-connected computers the same way: by
their numeric Internet Protocol (IP) Addresses.
Soon, the impracticality of memorizing all these numbers
became obvious, and a rudimentary naming scheme was developed. A central
repository of names and their associated IP addresses was created and
maintained in the form of a plain list. Periodically, administrators would
connect to this central repository and download the current list of computer
names. As the number of computers (hosts) on the Internet increased, this file
began to grow exponentially, and keeping the hosts file up to date became a
much more time-consuming task. The early pioneers of the Internet realized that
this system would prove to be very difficult to scale.
So, the host naming process went under the knife in order to
develop a more scalable system with distributed management. And so, the Domain
Name System (aka "DNS") was born. The proud parents proceeded to inscribe every
detail of their creation and created the DNS Internet standards as defined by
RFC 1034 and RFC 1035. |
|
|
Implementation
DNS fulfilled its goal of becoming an efficient,
distributed, and scalable system for resolving human-readable hostnames to
network-usable IP addresses. DNS's designers also decided on a particular
hierarchy. They created a naming format in which the computer would be known by
its name, followed by a hierarchical list of domains, which were simply logical
zones that the computer fell into for management purposes. These names are
separated by dots and written in reverse order (broadest domain last). For
example, a typical name looks like this:
www.thisismydomain.com
Since the domain name trees from right to left, we can
interpret that the broadest domain is "com". The "com" domain represents the
portion of the name space that is set aside for commercial enterprise, and most
typically for commercial entities within the United States. This portion of the
name is known as the top-level domain. "thisismydomain" represents what is
called the second-level domain name and generally represents the firm that
actually owns or controls the domain and all the hostnames beneath it. This
leaves "www" which is the hostname or the actual computer name as assigned by
local administration.
Incidentally, the combination of the second-level and
top-level domain is what is commonly referred to as the domain name. Entities
who wish to set up and control their own domains must choose a top-level name
space to operate in, and decide on a second-level name. Then, they must contact
one of a group of central authorities that oversee the top-level name space and
register this domain name. These central authorities are appropriately deemed
registrars. While selecting a second-level domain name that directly represents
your firm's name is a convention, there is no rule requiring it. Anyone can
register any name they choose providing that the standard naming rules are
adhered to and the name is available. |
| |
Resolution
Now that we know why a naming system exists and have seen
what a name looks like, let's take a look at how a name actually gets
translated back into an address that computers can use.
The easiest way to understand this process is with an
example. Let's imagine that an Internet user wants to look up information on a
website. We'll use a fictitious site, "http://www.example.com".
First, the user types the above URL into his web browser and
the computer begins processing the web request. The user's computer must find
the IP address for "www.example.com" before it can contact the correct server.
(The initial characters "http://" simply tell the web browser what protocol to
use to contact the remote computer once it has an address.)
The web browser then turns this hostname over to the
resolver. A resolver is just a computer program or process that runs silently
on any computer connected to the Internet that needs to be able to translate
names to IP addresses. Its sole purpose is to perform this task, and it does so
very quietly. So much so that most Internet users have never heard of it!
The resolver checks its own internal tables to see if it has
any information stored or cached containing the IP address for the requested
hostname. If not, the resolver checks its configuration for the IP address of a
name server to which it can pass the query. In most cases, the client resolver
will have to connect to this name server to answer the query, unless it has
been looked up recently and is in the resolver cache or has been manually
entered in the local resolver's host table. The next server in the chain for
the average user is usually a DNS server that an Internet Service Provider owns
and maintains. Corporate entities may maintain their own DNS servers. The
location of the server is not important, so long as the resolver can connect to
it reliably. This server is usually very near the user's Internet connection
point and is referred to as the recursive server . |
| |
|
It is at this step in the resolution chain that we must
introduce the concept of authority. Every registered domain name is required to
select two or more name servers that will pass on "official" data for that
domain name to the rest of the Internet when asked. Domain owners can't just
pick any name server out of a hat. They must either maintain their own name
server or coordinate with the administrators of an existing server to provide
DNS services (which usually involves a fee).
The recursive server, upon receiving a query from the
resolver, checks to see if it is authoritative and has the information for the
zone requested in its local configuration or cache. If a server is supposed to
be authoritative for a domain but does not have any information for the domain
or isn't configured to handle it, it causes a "lame delegation", where no
queries are properly answered. If the recursive server can't resolve the query
on its own, it too will need a "next step" to take. But, what servers can it
ask, and how does it know about them? A name server that responds to queries
should have a file containing a listing of names and addresses of Internet root
servers.
A root server is a particular type of domain name server on
the Internet that stores top-level naming information and second-level
delegations. In English: root servers tell the recursive servers where to go
find out more information about the domain they're querying.
Now, our query has made it from the client resolver to the
recursive server to the root server, and the root server has found the server
that should have the necessary information to respond to the query. We'll call
this the authoritative server. The root server now passes this address back to
the recursive server. Finally, the recursive server must contact the
authoritative server and issue the original query. It will then return that
result to the recursive server. The recursive server delivers the result to the
client and potentially caches the query result. The client resolver hands off
the IP address in question to the actual network protocols to locate the IP
address and establish a connection, and the resolution process is complete.
|
| |
Expansion
Resource records are the foundation of DNS. Every piece of
information that DNS can provide about a host or domain is stored as a resource
record (aka RR). Dozens of different resource-record types (also called
RRtypes) exist to help define the type(s) of DNS information available. We'll
take a look at a few common types.
Address (A)
Address (A) records are the "meat" of DNS. The A record
stores the IP address associated with a given hostname. Most DNS operations are
queries for A records. A few things to note: An A record must always point to a
single IP address. No other form of entry is acceptable. Multiple A records can
be entered with the same name (called a label). The DNS server will return all
the IP addresses listed. Clients will generally try the first address listed,
so order is important. Depending on implementation, this order can be round
robin or selected based on topological proximity. Multiple labels can be
assigned the same IP address. In this case, querying any one of the labels will
return the IP address. It is possible to have an A record for a label that has
the same name as your domain. (For example, "example.com" is a domain, but an A
record can also be created to make "example.com" directly resolve to an IP
address. |
| |
Canonical Name (CNAME)
Canonical Names (CNAMEs) are the DNS equivalent of aliases
or symbolic links. This record's function is to point a hostname to another
hostname. For this to be useful, the "destination" hostname must have an A
record which points to some IP address. A few important points about CNAMEs:
CNAMEs can point to any hostname on any domain anywhere in the world,
regardless of who owns the domain or where it is located. CNAMEs require that
both the destination host and the destination host's A record (IP address) be
returned in order to properly resolve. As such, CNAMEs are generally slower
than A records and should be used sparingly. A domain name can not be used as a
CNAME label. (For example: setting up "exampleeeks.com" to resolve as a CNAME
to "www.someprovider.net" will not work. Currently, most name server software
will let you try anyway. CNAMEs can not point to URL's, nor can they point to
specific directories on your web server. A CNAME can only point to a hostname
with a valid A record.
Pointer (PTR)
Pointers are essentially the opposite of "A" records, in
that they resolve IP addresses back to hostnames. Although it's not a required
function of DNS, some applications like to use an inverse query to authenticate
or provide more information about a connected or connecting host. A few things
about PTR's to be aware of: Just like a domain name, a name server must be
configured to be authoritative for the block of IP addresses and the root
servers must be aware of this delegation. The smallest standard block that can
be authoritatively delegated is currently 256 IP addresses (otherwise known as
a "/24" or somewhat incorrectly as a "Class C"). There are proposed mechanisms
to allow sub-delegation of PTR responsibility to even smaller blocks, but no
standard is in place as of the writing of this document. You do not have to set
up PTR's for your hostnames and your domains to resolve correctly. Some
applications may call for it, but it is not required by any Internet standard.
|
| |
Start of Authority
The SOA record defines the given name server's authority for
the domain. In addition to authority, the SOA record also contains several
configuration parameters for the domain, as follows: Person In Charge - E-Mail
Address of the person responsible for the domain's administration. Serial
Number - This number must be incremented each time a change is made to the
records for a domain/zone. If a zone is changed but the serial number is not
updated, the secondary server will not acquire the new data when it refreshes
its zone information. Refresh - How often, in seconds, a secondary name server
is to check with the primary name server to see if an update is required. Retry
- If a secondary server tries to poll the primary server and fails, the
secondary should wait this number of seconds before trying again. Expire - If
the secondary server is not able to update its data by contacting the primary
server for this number of seconds, it will stop using the data it has for
queries, in case the data is outdated or inaccurate. Minimum TTL - TTL time is
a per-record specification that tells any querying name server how long it
should keep that particular record in its cache. The Minimum TTL field is a
zone wide default that is used when a record does not explicitly specify its
own TTL time.
Name Server (NS)
NS records supply the hostname of the authoritative name
server(s) for the domain. Every domain must have an NS record, and current RFC
guidelines specify no fewer than two. Domains can also be divided into
sub-domains as specified by local administrators, and each sub-domain can have
its own NS records. |
| |
Mail Exchanger (MX)
MX records specify the hostname of the server that will
handle mail for this domain. When you send mail to postmaster@example.com, your
local mail server has to contact the server that handles mail for "example.com"
and pass the e-mail on to it. But which server should it contact?
mail.example.com? postoffice.example.com? example.com? Or, perhaps some server
belonging to an entirely different domain?

Since the server that handles mail for a domain could
feasibly be any server on the Internet, the host attempting to deliver mail
must have some way to find out the address of the server to contact. This is
precisely the role of the MX record. The MX record has three parts: a domain
name, a hostname, and a preference value. The domain name for the above example
would be "example.com". The hostname is the name of the server to which mail
for this domain will be delivered. Incidentally, this server must also be
configured to accept and handle mail for the given domain. The preference value
is a number (usually between 0 and 100) to indicate which MX record to try to
use first if more than one exists. A lower number will always be used before a
higher number. This allows for some redundancy if the preferred mail-handling
host loses connectivity or the ability to accept mail for delivery. |
| |
A few caveats:
MX records are not equivalent to e-mail addresses. They can
not contain a user name, only a hostname. The mail server for your domain
handles "everything before the '@'" on its own. MX records should never point
to a CNAME record, only a host that has a valid A record. MX records can not
point to an IP address. The server you are pointing to will not begin handling
mail for you until you let the server's administrator know, and that
administrator configures the server to accept e-mail for your domain.
Wildcards
The character used as a wildcard in most DNS implementations
is the asterisk or "*"character. You may use this character in certain RRTypes
to match any hostname beneath your domain. So what happens when you set up an A
record for "*.example.com" to point to "127.0.0.1"? Every possible hostname
will resolve to that IP address. So, with this entry in place,
"www.example.com" would resolve to "127.0.0.1", "mail.example.com" will resolve
to "127.0.0.1" and even "we.love.example.com" will resolve to "127.0.0.1", all
because of a single wildcard record that matches everything. You can also do
this for MX records. Suppose someone sends mail to "somebody@example.com".
We've just read that an MX record lookup for "example.com" would be performed
and that mail would be delivered to the host returned in the MX query. But,
what if someone sends mail to "somebody@mail.example.com", or
"somebody@anything.example.com"? The answer is that the mail will not be
delivered, since an MX record for these hostnames does not exist. Rather than
adding every possible hostname as an MX record, DNS allows you to specify
"*.example.com" as an MX record label, to catch all possible hosts. |
| |
Closure
We hope that this guide has given you a basic understanding
of the Domain Name System. If you should desire a more in-depth tutorial, we
recommend the book
DNS and BIND,
published by O'Reilly.
There's no substitute for a good book and hands-on experience, but the
information contained here and in the other sections of our website should be
enough to get you started.
Copyright © 2000 - 2001
UltraDNS Corp., All rights
reserved. |
|