WWW FAQs: What is DNS?


2003-09-04: every time you follow a link or type in the name of a website, such as www.boutell.com, that name must be translated into an IP address on the Internet. This translation is done by the domain name system. A DNS server is a program that participates in the task of providing this service. Some DNS servers respond to queries from web browsers and other programs, make further inquiries, and return IP addresses, such as 208.27.35.236, which is the current IP address of www.boutell.com. Other DNS servers have primary responsibility for answering DNS inquiries about names within a particular domain, such as the boutell.com domain. Every time a new domain is registered, a DNS server must be configured to give out address information for that domain, so that users can actually find websites in that domain. In most cases, web hosting companies provide this service for the domains that they host; it is rare for webmasters to run their own DNS servers. For more information, see setting up websites.

How DNS Usually Works

Let's say you want to visit www.google.com. Your computer hasn't already looked up www.google.com since it was turned on. Or it has kept that information for long enough that it considers it appropriate to check again. So your computer asks the DNS server of your ISP (Internet Service Provider - the people who sell you an Internet connection, companies such as Comcast and Earthlink).

The DNS server of your ISP first talks to one of thirteen "root" DNS servers. The root DNS servers answer questions at the highest level possible: the top-level domain. For instance, "who is in charge of DNS for the com domain?"

In practice, your ISP's DNS server caches (remembers) this information for a significant period of time, and does not contantly harrass the root servers just in case responsibility for com has changed in the last five seconds. Similarly, your ISP's DNS server remembers other informaton for appropriate lengths of time as well to avoid extra queries. But let's assume, just for fun, that no one has ever asked your ISP for the IP address of www.google.com before!
Now your ISP's DNS server knows which DNS servers are responsible for the com top-level domain. So your ISP's DNS server reaches out and contacts one of those servers and asks the next question: who is responsible for DNS in the google.com domain?

The response will list two or more DNS servers that have authority over the google.com domain.

Finally, your ISP's DNS server contacts one of those DNS servers and asks for the address of www.google.com, and hands the response back to your computer.

As mentioned above, in real life your ISP's DNS server will remember all of this information. That means that a typical user will get an immediate response when asking for the address of a frequently-visited site like Google.

But how long is it safe to remember that information? After all, the IP addresses of servers do change, though usually not often. Fortunately, your ISP's DNS server doesn't have to guess! The DNS records that come back from the "upstream" DNS servers include an "expire" field that indicates how long the information can be kept before the authoritative server should be asked again.

Legal Note: yes, you may use sample HTML, Javascript, PHP and other code presented above in your own projects. You may not reproduce large portions of the text of the article without our express permission.

Got a LiveJournal account? Keep up with the latest articles in this FAQ by adding our syndicated feed to your friends list!