SC250
Computer Networking I
Application Layer: Domain
Name System (DNS)
Prof. Matthias Grossglauser
LCA/I&C
[Link]
1
Today's objectives
Domain Name System (DNS)
Background and motivation
Name space
DNS architecture
DNS protocol
nslookup command
2
Background and Motivation
3
Application layer
Host Router Host
Application Application
Transport Transport
Network Network Network
Link/Physical L/P L/P Link/Physical
4
DNS: Domain Name System
People: many identifiers: Domain Name System:
SSN (CH: AVS), name, distributed database
passport # implemented in hierarchy of
Internet hosts, routers: many name servers
application-layer protocol
IP address (32 bit) - used
host, routers, name servers
for addressing datagrams
to communicate to resolve
“name”, e.g., names (address/name
[Link] - used translation)
by humans note: core Internet
How to map between IP function, implemented as
addresses and names? application-layer protocol
complexity at network’s
“edge”
5
Early ARPANET: [Link]
Centralized file containing entire name-address mapping
updated and disseminated every few days
NET : [Link] : LOOPBACK :
NET : [Link] : CMU-NET :
NET : [Link] : LBL-IP-NET1 :
NET : [Link] : DCNET :
NET : [Link] : RUTGERS :
NET : [Link] : EKONET :
NET : [Link] : UMDNET :
NET : [Link] : ISI-NET :
NET : [Link] : BBN-CRONUS :
NET : [Link] : SU-NET :
....
HOST : [Link] : [Link] : VAX-11/750 : VMS :TCP/TELNET,TCP/FTP :
HOST : [Link] : [Link] : C/30 : TAC : TCP,ICMP :
HOST : [Link] : [Link] : WANG-VS100 : VSOS ::
HOST : [Link], [Link], [Link], [Link] : [Link] ::::
HOST : [Link] : [Link] : C/30 : TAC : TCP,ICMP :
HOST : [Link] : [Link] : C/30 : TAC : TCP,ICMP :
6
Problems with centralized approach
Scalability
with n names -> n2 work
Single point of failure
e.g., if file is corrupted, entire Arpanet would collapse
Cumbersome
updating, regular downloads, installing file
Collisions
no mechanism to avoid allocating same name multiple times
Consistency
“view” of network not always the same
7
DNS: decentralized approach
Distributed database
relation name - IP address
clear delegation of authority – who owns parts of namespace,
who updates the database?
scales well
name servers
primary, secondary - authoritative data
cache - non-authoritative data
resolver:
gethostbyname()
gethostbyaddr()
Hierarchical name space
similar to Unix pathnames, but reversed
unix: /usr/local/bin/emacs
DNS: [Link]
8
DNS overview
DNS offers one distributed world-wide database
distributed according to the zone concept: every zone has a
master file describing all records under the zone’s authority
name servers hold their part of the database
for one zone, at least two name servers have the zone
information, copied from master file
– exam p l e: [Link], [Link];
[Link], [Link]
zone information held by the name server is called
authoritative data
one name server may hold zone data for one or more zones
zone data contains pointers to name servers holding
authoritative data for subzones
Root servers
13 servers distributed all over the world
any primary server needs to know their addresses
9
Name Space
10
Name and address spaces
Sample name
Sample IP address
[Link] [Link]
Hierarchical Hierarchical
least specific to the right least specific to the left
(“edu”) (“128”)
Mainly useful to humans
Mainly useful to machines
human-readable reference machine-readable
to hosts, networks, email reference to hosts and
domains, etc. networks
Size (virtually) unlimited
Size limited
variable-size names, short, fixed-sized addresses
human readable to maximize efficiency
11
Name space: domain name tree
root
top level
generic domains domains country domains
arpa com edu gov mil net org ch … us … za
in-addr 2nd level ethz epfl
domains
128 ibm ee lrcsuns ssc
178 tik
zurich
156
www
24
[Link].[Link] [Link]
every node on the tree represents one or a set of
resources
every node on the tree has a label (lrcsuns) and a
domain name ([Link])
12
DNS names
Node
label <= 63 characters (letters, digits, and -)
case-insensitive
Name
list of labels separated by .
[Link]. (fully qualified domain name)
lcawww (local name - evaluated with respect to the
local domain)
Analogous to unix file names
/usr/local/bin/emacs (root of tree to the left)
[Link] (root of tree to the right)
13
DNS names
Hierarchical naming authority
top level: ICANN (Internet Corporation For Assigned Names
and Numbers)
any organization can apply to become authority for a
subdomain, e.g.:
SWITCH for ch. and li.
EPFL for [Link].
any authority can create subdomains and delegate recursively
unilaterally
14
DNS Architecture
15
DNS name servers
Why not centralize DNS?
No server has all name-to-
single point of failure IP address mappings
traffic volume Local name servers:
distant centralized each ISP, company has
database local (default) name server
maintenance host DNS query first goes
doesn’t scale! to local name server
Authoritative name server:
for a host: stores that
host’s IP address, name
can perform name/address
translation for that host’s
name
16
root name
DNS example 1 server
host [Link]
2 4
wants IP address of 5 3
[Link]
1. contacts its local DNS
server, [Link]
2. [Link] contacts local name server authorititive name server
[Link] [Link]
root name server, if
necessary 1 6
3. root name server contacts
authoritative name
server, [Link], if
requesting host
necessary [Link]
[Link]
17
root name
DNS example 2 server
Root name server:
2 6
may not know 3
7
authoritative name
server
may know
intermediate name
local name server intermediate name server
server: who to [Link] [Link]
contact to find 5
4
authoritative name 1 8
server
authoritative name server
[Link]
requesting host
[Link]
[Link]
18
root name
DNS example 3 server
recursive query: i t er at ed
2
puts burden of 3
qu er y
name resolution on
contacted name 4
server 7
heavy load?
local name server intermediate name server
iterated query: [Link] [Link]
contacted server 1
5 6
8
replies with name
of server to authoritative name server
contact [Link]
“I don’t know this requesting host
[Link]
name, but ask this
server” [Link]
19
Name management
Zone = a connected subset of nodes
property: a zone has one single node closest to the root =
top node, used to name the zone
name authority matches zone boundaries:
names and subzones, can be created and deleted by the
authority responsible for a zone; examples:
– [Link] is a subzone of [Link]
– zone [Link]. has authority delegation from
[Link].
at least 1 name server per zone (port 53)
primary, secondary - copy of the primary
/etc/[Link]: nameserver [Link]
domain [Link]
replication - secondary servers
cache - data kept for 1 day
20
Zones and domains
delegation
“”
com org
edu
edu zone
berkeley stanford mit
edu domain
21
Zones and domains
Domains:
Zones:
subtrees of the name space nodes in name tree under
single administrative
control
domain x.y.z contains all zone x.y.z does not contain
nodes below x.y.z those nodes below x.y.z for
which the zone delegates
to another zone
independent of delegation delegation relationships
relationships define its boundaries
22
Zones and domains
“”
com org
edu
berkeley stanford mit
edu zone
edu domain
23
Zones and domains
“”
com org
edu
berkeley stanford mit
edu zone
edu domain
24
DNS root name servers
Contacted by local name server that can not resolve name
Root name server:
contacts authoritative name server if name mapping not known
gets mapping
returns mapping to local name server
a NSI Herndon, V A
c PSInet Herndon, V A k RIPE London
d U M aryland College Park, M D i NORDUnet Stockholm
g DISA V ienna, V A
m W IDE Tokyo
h A RL A berdeen, M D
e NA SA M t V iew, CA j NSI (TBD) Herndon, VA
f Internet Software C. Palo Alto,
CA
13 root name
servers
b USC-ISI M arina del Rey, CA
l ICA NN M arina del Rey, CA
worldwide
25
DNS Protocol
26
Iterative query
[Link]. A?
root NS
ask name server d1
…
[Link]. A ?
d1 NS
[Link]
my NS
[Link]
[Link]. A ?
Note: servers usually issue iterative queries to other
servers 27
Recursive query
[Link].A ?
root NS
[Link]
[Link] A? delos
my NS d1 NS
[Link]
[Link].A ?
Note: resolvers always issue recursive queries to their
local nameservers 28
1 2
stisun1 3 root
lrcsuns name name
Example:
resolver server 4 server
Query
6
5
Processing
watson
1 query, RD=yes [Link].
question = “[Link]. A”
2,4 query, RD=no
question = “[Link]. A”
3 answer
question = “[Link]. A”
answer = ““
autority= “[Link]. NS [Link].
NS [Link].
NS [Link].“
additional=“[Link]. A [Link]
[Link]. A [Link]
[Link] A [Link]“
5,6 answer
question = “[Link]. A”
answer = “[Link]. A [Link]“
29
Reverse mapping IP-address to name
Question:
How can we find the name(s) that an IP address corresponds to?
Answer:
Conceptually, just search through all resource records and find
the ones that match
How to do this in a distributed way?
Key observation:
IP address space is also hierarchical
...but this hierarchy has nothing to do with naming hierarchy
Example: tinycorp get IP addresses [Link]-
[Link] from their ISP, and the name
“[Link]” from an ICANN-accredited registrar
Solution:
build an additional domain that maintains this mapping:
[Link] 30
[Link] domain for reverse lookups
“”
Mapping IP=[Link]
look up [Link].[Link] arpa
in-addr
0 1 255
0 2 255
0 3 255
0 4 255
31
Pointer query: IP address back to name
[Link].[Link]. PTR ?
root NS
ask d1
[Link].[Link]. PTR ?
d1 NS
[Link].
my NS
[Link].
[Link] PTR ?
32
Performance and robustness
Replication
multiple servers with identical zone data
load balancing and failover
Caching: once (any) name server learns mapping,
it caches, i.e., remembers, this mapping
cache entries timeout (disappear) after some time:
TTL (time to live) defined by authoritative name
server
reduce traffic by creating “shortcuts” in walking down
the tree
33
Replication
Zone data is replicated
primary server holds master file on disk
secondary servers poll primary servers (ex: every 3
hours)
using the SERIAL field in the zone data
copying is called zone transfer; uses TCP (queries usually
use UDP)
changes in zone data by system manager:
update master file
signal primary name server to reload; new value of
SERIAL field automatically created
secondary servers will discover the change
automatically
zone data in secondary servers is authoritative
34
Server selection
How does a name server select among multiple potential
servers in a lookup?
we'd like to use “close” servers
example: [Link] name servers + RTTs (from ping):
[Link] nameserver = [Link]. RTT=200ms
[Link] nameserver = [Link]. RTT= 30ms
[Link] nameserver = [Link] RTT=200ms
Solution:
name server measures RTT of queries it sends to servers
over time, it will converge to using the closest and best
performing of potential servers
35
Caching: request for
[Link]
root
server
edu.
“ask NS for [Link]”
berkeley.
local NS edu.
“ask NS for [Link]”
eecs.
berkeley.
resolver edu.
36
Caching: subsequent request for
[Link]
root
local NS cache: server
edu NS [Link]
[Link] NS [Link]
[Link] NS [Link]
[Link] A [Link]
edu.
berkeley.
local NS
edu.
eecs.
berkeley.
resolver edu.
37
Caching: subsequent request for
[Link]
root
local NS cache: server
edu NS [Link]
[Link] NS [Link]
[Link] NS [Link]
[Link] A [Link]
edu.
berkeley.
local NS
edu.
eecs.
berkeley.
resolver edu.
38
Details of a query
IP dest addr = [Link]
protocol = UDP
lrcsuns source port = 1267 dest port = 53 stisun1
DNS message =
header = query,
application
question = (QNAME=“[Link].” QTYPE=A)
program
DNS query 2
name 3 DNS answer name
resolver server
IP dest addr = [Link]
protocol = UDP
source port = 53 dest port = 1267
DNS message =
header = response, AA
question = (QNAME=“[Link].” QTYPE=A)
answer = ([Link]. TTL=86400 TYPE=A [Link])
zone data (authoritative data)
[Link] RR type
A = IPv4 addr
nameserver [Link] [Link]. 86400 A [Link]
AAAA = IPv6 addr
nameserver [Link] [Link]. 86400 A [Link]
domain [Link] 86400 A [Link]
cached data (non-authoritative data)
Resource Records (RRs)
keyed by domain names [Link]. 1770 A [Link]
39
DNS records
DNS: distributed db storing resource records (RR)
RR format: (name, value, type,ttl)
Type=A Type=CNAME
name is hostname name is alias name for some
value is IP address “canonical” (the real) name
[Link] is really
Type=NS
[Link]
name is domain (e.g.
value is canonical name
[Link])
value is IP address of Type=MX
authoritative name
server for this domain
value is name of
mailserver associated with
name
40
DNS protocol, messages
DNS protocol:
query and reply messages, both with same message
format
usually uses UDP: query+reply fit in single packet, delay
important, reliability handled by DNS itself
Message header
identification: 16 bit #
for query, reply to
query uses same #
flags:
query or reply
recursion desired
recursion available
reply is
authoritative 41
DNS protocol, messages
Name, type fields
for a query
RRs in response
to query
records for
authoritative servers
additional “helpful”
info that may be used
42
nslookup command
43
nslookup: look up a host
$ nslookup [Link]
Server: [Link]
Address: [Link]
Non-authoritative answer:
Name: [Link]
Address: [Link]
Origin of information
“non-authoritative”: from some NS's cache
“authoritative”: from (one of the) authoritative servers
44
nslookup: look up nameserver
$ nslookup -querytype=NS [Link] [Link]
Server: [Link]
Address: [Link]
[Link] nameserver = [Link]
[Link] nameserver = [Link]
[Link] internet address = [Link]
[Link] internet address = [Link]
45
nslookup: reverse mapping IP->name
$ nslookup -querytype=PTR [Link]
Server: [Link]
Address: [Link]
[Link].[Link] name = [Link]
[Link] nameserver = [Link]
[Link] nameserver = [Link]
[Link] nameserver = [Link]
[Link] internet address = [Link]
[Link] internet address = [Link]
[Link] internet address = [Link]
[Link] internet address = [Link]
46
nslookup: other points
Interactive and noninteractive modes
Interactive: session with its own prompt, issue commands
Noninteractive: everything from command line (like preceding
examples)
Can behave like a resolver or like a name server
e.g., can issue both recursive (like resolver) or iterative
(usually done by name servers) queries
Option to see query and response messages
debug option
47
DNS: summary
Hierarchical name space
natural way to delegate portions of the space
natural way to distribute mapping functionality
Name servers all over the world
Scalable
distribution and authority delegation
caches for efficiency (reduce traffic)
replication for fault tolerance (server outage)
One of the key features of the Internet
...and key source of problems (e.g., delay)!
Most popular implementation: BIND
Recent trends:
DNS increasingly used for sophisticated tasks it was not
originally designed for, e.g., load-balancing among web servers
security 48