Cryptography Reference
In-Depth Information
domain and then the authoritative name server for the next-level domain. When
it fi nds an authoritative server for the actual requested host name, it issues a
query to that server.
Using the DNS Protocol to Query the Database
You may be curious, though, about how gethostbyname actually queries the
database. These days, if I say database , you may start thinking about SQL and
SELECT statements, but the DNS naming system, thankfully, predates the rela-
tional database craze and instead defi nes its own Internet protocol. This proto-
col is named, unsurprisingly, DNS, and is an interesting protocol in the way it
structures requests and responses.
The DNS database is a collection of resource records (RR) as illustrated in
Figure 10-3, each of which has a name, a type, a class, and a set of associated
data that varies depending on the type. The most important type of resource
record is type A , Host Address , which actually describes the mapping between a
host name and an IP address. Type A, Host Address, RRs include an IP address
in the associated data section. So, if a client has a host name for which it wants
to query the corresponding IP address, it fi lls out as much information as it
has on the RR, sends that to the server, and the server responds with as much
information as it has — hopefully a completed record. The resource record itself
is pretty open-ended — other available and common resource records include
load-balancing information, redirect information, and mail server information.
NAME
TYPE
CLASS
TTL
DATA LENGTH
DATA
Figure 10-3: Resource record format
Disadvantages of the DNS Query
Normally, this query is submitted not with a TCP socket, but with a UDP (data-
gram) socket, on port 53. UDP Requests and responses aren't rigidly matched
Search WWH ::




Custom Search