The Domain Name System or DNS is a system that stores information about host names and domain names on networks, such as the Internet. Most importantly, it provides an IP address for each host name, and lists the mail exchange servers accepting e-mail for each domain.
The DNS forms a vital part of the Internet, because hardware requires IP addresses to perform routing, but humans use host names and domain names, for example in URLss and e-mail addresses.
Paul Mockapetris invented the DNS in 1983; the original specifications appear in RFC 882. In 1987 the publication of RFC 1034 and RFC 1035 updated the DNS specification and made RFC 882 and RFC 883 obsolete. Several more recent RFCs have proposed various extensions to the core protocols.
A domain name consists of two or more parts (technically labels) separated by dots. The rightmost label conveys the top-level domain (for example, the address www.wikipedia.org has the top-level domain org). Each label to the left specifies a subdivision or subdomain (for example, wikipedia.org is a subdomain of org and www.wikipedia.org is a subdomain of wikipedia.org). In theory, this subdivision can go down to 127 levels deep, and each label can contain up to 63 characters, as long as the whole domain name does not exceed a total length of 254 characters. But in practice some domain registries have shorter limits than that.
The DNS consists of a hierarchical set of DNS servers. Each domain or subdomain has one or more authoritative DNS servers that publish information about that domain. The hierarchy of authoritative DNS servers matches the hierarchy of domains.
An example may clarify this. Suppose a web browser needs to find out the IP address of www.wikipedia.org. The browser starts out knowing only the IP address of a root server, say 198.41.0.4. It asks the DNS server at that address for the address of www.wikipedia.org. The root server replies with a delegation meaning roughly, "I don't know the address of www.wikipedia.org, but I do know that the DNS server at 204.74.112.1 has information on the org domain." The browser then asks that DNS server, which replies, "I don't know the address of www.wikipedia.org, but I do know that the DNS server at 207.142.131.234 has information on the wikipedia.org domain." The browser asks this third DNS server, which replies with the required IP address.
A number of practical refinements to this system exist:
Host names and IP addresses do not necessarily match on a one-to-one basis. Many host names may correspond to a single IP address: combined with virtual hosting, this allows a single machine to serve many web sites. A single host name may correspond to many IP addresses: this can facilitate load balancing.
The task of performing DNS lookups usually falls to a DNS cache which remembers (for a limited time) the answers to all the queries it has asked. An organization or Internet service provider may run a DNS cache for all its users.
To provide resilience in the event of computer failure, multiple DNS servers provide coverage of each domain. In particular, thirteen root servers exist worldwide. DNS programs or operating systems have the IP addresses of these servers built in. The USA hosts, at least nominally, all but three of the root servers. However, because many root servers actually implement anycast, where many different computers can share the same IP address to deliver a single service over a large geographic region, most of the physical (rather than nominal) root servers now operate outside the USA.
The DNS uses TCP and UDPports 53 to serve requests. Almost all DNS queries consist of a single UDP request from the client followed by a single UDP reply from the server. TCP is typically used only when the response data size exceeds 512 bytes, or for such tasks as AXFR.
An MX record or mail exchange record maps a domain name to a list of mail exchange servers for that domain.
A PTR record or pointer record maps a host name to the canonical name for that host. Setting up a PTR record for a host name in the in-addr.arpa domain that corresponds to an IP address implements Reverse DNS lookup for that address. For example (at the time of writing), www.icann.net has the IP address 192.0.34.164, but a PTR record maps 164.34.0.192.in-addr.arpa to its canonical name, referrals.icann.org.
An NS record or name server record maps a domain name to a list of DNS servers for that domain.
An SOA record or start of authority record specifies the DNS server providing authoritative information about an Internet domain.
Other kinds of records simply provide information (for example, an LOC record gives the physical location of a host), or experimental data (for example, a WKS record gives a list of servers offering some well-known service such as HTTP or POP3 for a domain).
For each of the 240+ Country Code top-level domains (ccTLDs) the registry (as part of its many functions) usually holds the entire authoritative WHOIS database for that extension.