amazon.com
and
ironbark.bendigo.latrobe.edu.au
.
ironbark
is
149.144.21.60
. IP addresses are used by the the routers
which implement the Internet's delivery service, the Internet
Protocol, or IP, to route packets of data through the Internet to
their destination. The Internet Domain Name System (DNS) is used to provide a mapping between these two alternative identification approaches: the human-oriented domain name and the delivery-oriented IP address. Its most common usage is to look up the IP address corresponding to a known domain name.
.com
, .edu
,
.org
) and a large number of country-based domains (eg
.au
, .my
, .uk
). Each
TLD supports a group of "second-level" domains, and so on, all the way down to
individual hosts.
bindi.bendigo.latrobe.edu.au.
Domain_name TTL Type Class Value
SOA
A
NS
IN
", for Internet
sheoak
is a nameserver for the zone bendigo.latrobe.edu.au.
This
means that if I want to look up a particular IP address in that zone, I can ask
sheoak
.
Exactly which server is responsible for a particular zone is specified in start of authority (SOA) RRs. An SOA RR specifies, for the particular name server, the zones for which it has authority. It also has the email address of the site administrator, a unique serial number and various other bits and pieces.
The DNS system forms a distributed database of domain information.
A resolver is a library function[1] which queries the nameserver when called from a user program. It can check the local cache of names and, if necessary, request a RR from a nameserver (caching the response). In other words, a resolver is software which asks a nameserver for information.
[1] Such as is built-in to the Unix
library function gethostbyname(3)
.
The server responds with one or more appropriate RRs. It also sends an ADDITIONAL INFORMATION section, which contains extra RRs which the resolver will probably find useful. For example, if a resolver queries for a particular{query domain name, type, class}
NS
RR, the server will return it, plus additional
information giving the IP address of the name server specified in the main body
of the reply.
The most common DNS query is of type A, where the resolver is required to map a domain name to an IP address - that is, "looking up" an IP address. Some typical type A RRs look like:
Note that the "domain name" part of these RRs has been omitted (leaving only the hostnames) for clarity.ironbark 86400 IN A 149.144.21.60 redgum 86400 IN A 149.144.21.3 bindi 86400 IN A 149.144.20.82
bendigo.latrobe.edu.au
) is configured to
"know" the IP address of its local nameserver. What happens when it sends a
query for a non-local name, (eg amazon.com
)? The sequence of
events is something like:
latrobe.edu.au
.
.com
domain, which will have the desired name-to-address
mapping.
ironbark IN MX 10 ironbark IN MX 20 redgum IN MX 40 sheoak
in-addr.arpa
) and address format is
used to map IP addresses to domain names, thus:
This is called a PTR RR. Performing reverse lookups is much more difficult than normal "forward" address lookups.60.21.144.149.in-addr.arpa
The DNS requires that all nameservers be replicated at least once -- that is, for each zone of authority there must be at least two authoritative nameservers. The rules for replication of nameservers make for quite entertaining reading...
DNS queries and responses are an excellent example of an application where the reliable, connection-oriented transport mechanism of TCP is not necessary, and simply has too much overhead. In fact, queries are encapsulated in unreliable UDP datagrams, see later. UDP is a connectionless transport service, with the same level of reliability as IP packet delivery itself -- in other words, UDP messages can be lost, delivered out of order and even duplicated. If a resolver does not receive a reply from a nameserver, it usually either tries again, or tries the next nameserver for the same domain.
Finally, although it is beyond the scope of our subject, DNS messages are NOT simple ASCII strings -- the DNS formats are quite complex and designed for efficient parsing. It's not trivial (for obvious reasons) to write a DNS client. In a sense, DNS is not strictly an application protocol -- it provides support for application protocols, but isn't one itself.