Title: Domain Name System DNS CS 352 Spring 2004
1Domain Name System (DNS)CS 352Spring 2004
2 Domain Name System (DNS)
- Problem statement
- Average brain can easily remember 7 digits
- On average, IP addresses have 12 digits
- We need an easier way to remember IP addresses
- Solution
- Use alphanumeric names to refer to hosts
- Add a distributed, hierarchical protocol (called
DNS) to map between alphanumeric host names and
IP addresses - We call this Address Resolution
3Domain Name Hierarchy
...
...
com
edu
net
gov
int
mil
org
ae
us
zw
rutgers
yale
yahoo
cnn
Country Domains
cs
eng
Generic Domains
4Domain Name Management
- The domain name hierarchy is divided into zones
- Zone A separate portion of the DNS hierarchy
- No two zones should overlap
- Name servers
- In each zone, there is a primary name server and
one or more secondary name servers - Name servers contain two kinds of address
mappings - Authoritative mappings For hosts within the zone
- Cached mappings For previously requested
mappings to hosts not in the zone
5Domain Name Hierarchy
...
...
com
edu
net
gov
int
mil
org
ae
us
zw
rutgers
yale
yahoo
cnn
cs
eng
6DNS Protocol
- When client wants to know an IP address for a
host name - Client sends a DNS query to the primary name
server in its zone - If name server contains the mapping, it returns
the IP address to the client - Otherwise, the name server forwards the request
to the root name server - The request works its way down the tree toward
the host until it reaches a name server with the
correct mapping
7DNS ProtocolExample
remus.rutgers.edu
Scenario remus.rutgers.edu tries to resolve an
IP address for venus.cs.yale.edu using a
recursive query
1
8
ns-lcsr.rutgers.edu
2
7
a.root-servers.net
3
6
yale.edu
4
5
cs.yale.edu
8DNS ProtocolAnother Example
remus.rutgers.edu
Scenario remus.rutgers.edu tries to resolve an
IP address for venus.cs.yale.edu using an
iterative query
1
2
ns-lcsr.rutgers.edu
3
4
a.root-servers.net
5
6
yale.edu
7
8
cs.yale.edu
9DNS Packets
- Clients communicate with DNS servers using either
TCP or UDP on port 53
0
15 16
31
Transaction Identification
Flags
Number of Questions
Number of Answer RRs
Number of Authoritative RRs
Number of Additional RRs
Questions (variable length)
Answer Resource Records (variable length)
Authoritative Resource Records (variable length)
Additional Resource Records (variable length)
10DNS Packet Fields
- Transaction Identification Random number used
to match client queries with name server
responses - Flags
- QR 0Query, 1Response
- opcode 0standard query, 1inverse query,
2status request - AA Authoritative answer
- TC Truncated DNS packet
- RD Recursion desired
- RA Recursion available
- rcode Return code. 0no error, 3name error
1 4 1
1 1 1 3
4
QR
opcode
AA
TC
RD
RA
(unused)
rcode
11DNS Packet Fields (contd)
- Transaction Identification Random number used
to match client queries with name server
responses - Number of Questions Number of DNS queries in
the packet - Not supported in many DNS servers!
- Number of Answer RRs Number of
non-authoritative DNS responses in the packet - Number of Authoritative RRs Number of
authoritative DNS responses in the packet - Number of Additional RRs Number of other DNS
responses in the packet (usually contains other
DNS servers in domain) - Questions Answers Variable length fields to
store DNS queries and DNS server responses
12DNS Queries
DNS Packet Question field contains a sequence of
queries
Query name (variable length)
Query Type
Query Class
Query Name Contains an encoded form of the name
for which we are seeking an IP address Query
Type 1IP address, 2name server, 12pointer
record, etc. Query Class 1Internet address
13Encoding Query Names
- DNS queries must be encoded in a special way
- Divide host address into segments whenever a
period appears - For each segment, store a byte representing the
length of the segment followed by the letters in
the segment - Store a zero byte at the end of the query
14Encoding Query NamesExample
remus.rutgers.edu
remus rutgers edu
NOTE These count fields are not the ASCII
characters 5, 7, 3 and 0!!!
15DNS Responses
DNS Packet RR fields contain a sequence of
resource records
Domain name (variable length)
Type
Class
Time-to-live
Resource Data (variable
length)
Resource data length
- Domain Name Encoded domain name for query
- Type Class Same as for query (1IP
1Internet) - Time-to-Live How long this responses will be
useful - Resource Data Contains the four-byte IP address
16DNS Compression
- DNS responses are often compressed to save space
- Compression algorithm
- If all or part of the domain name field appears
earlier in the packet (e.g., in a prior RR), then
store a pointer to the earlier copy instead - Pointer 2-byte code
1
1
Index Pointer into DNS Response Packet
17DNS Caching
- Going to the root server and then down the tree
every time we need to resolve an address is
inefficient - Introduce address caching at name servers
- Store host-to-IP-address mappings from recently
requested host names at name server - When the same address is requested later, use the
cached version at the local name server instead
of recursively querying other name servers again
18DNS CachingExample
remus.rutgers.edu
1
8
First time remus.rutgers.edu tries to resolve
an IP address for venus.cs.yale.edu using a
recursive query
Later venus.cs.yale.edu has been cached at
ns-lcsr. remus.rutgers.edu (and any other host
that uses ns-lcsr) will receive the cached IP
address for venus.cs.yale.edu
ns-lcsr.rutgers.edu
remus.rutgers.edu
2
7
1
2
a.root-servers.net
ns-lcsr.rutgers.edu
3
6
yale.edu
4
5
cs.yale.edu
19Interface to DNS
- The dig and nslookup programs provide an
interface to DNS - dig remus.rutgers.edu
- Server ns-lcsr.rutgers.edu
- Address 128.6.4.4
- Name remus.rutgers.edu
- Address 128.6.13.3
20Bootstrapping DNS
- How does a host contact the name server if all it
has is the name and no IP address? - IP address of at least 1 nameserver must be given
a priori - or with another protocol (DHCP, bootp)
-
- File /etc/resolv.conf in unix
- Start - settings- control panel- network
-TCP/IP - properties in windows
21Default Domains
- When Host issues a query to DNS server, can add
the default domain. - Default domain added to end of ever DNS query
- E.g. default domain is rutgers.edu
- Machine eden automatically extendend to
eden.rutgers.edu
22Reverse DNS
- We have the IP address, but want the name
- Use DNS to perform the lookup function
- Special domain, in-addr.arpa domain for reverse
lookups - Internet address is reversed in the lookup
- E.g. 3.13.6.128.in-addr.arpa remus
- Follows least- most specific convention