Domain Name System (DNS) : Reading: Section 9.1
Domain Name System (DNS) : Reading: Section 9.1
Jennifer Rexford
• Inner-workings of DNS
– DNS resolvers and servers
– Iterative and recursive queries
– TTL-based caching
• IP addresses
– Numerical address appreciated by routers
– Fixed length, binary number
– Hierarchical, related to host location
– Examples: 64.236.16.20 and 193.30.227.161
4
Separating Naming and Addressing
• Names are easier to remember
– www.cnn.com vs. 64.236.16.20
• Addresses can change underneath
– Move www.cnn.com to 64.236.16.20
– E.g., renumbering when changing providers
• Name could map to multiple IP addresses
– www.cnn.com to multiple replicas of the Web site
• Map to different addresses in different places
– Address of a nearby copy of the Web site
– E.g., to reduce latency, or return different content
• Multiple names for the same address
– E.g., aliases like ee.mit.edu and cs.mit.edu 5
Strawman Solution: Local File
• Original name to address mapping
– Flat namespace
– /etc/hosts
– SRI kept main copy
– Downloaded regularly
6
Strawman Solution #2: Central Server
• Central server
– One place where all mappings are stored
– All queries go to the central server
9
TLD and Authoritative DNS Servers
• Top-level domain (TLD) servers
– Generic domains (e.g., com, org, edu)
– Country domains (e.g., uk, fr, ca, jp)
– Typically managed professionally
Network Solutions maintains servers for “com”
Educause maintains servers for “edu”
10
Distributed Hierarchical Database
unnamed root
foo my usr 34
my.east.bar.edu usr.cam.ac.uk
56
11
12.34.56.0/24
Using DNS
• Local DNS server (“default name server”)
– Usually near the end hosts who use it
– Local hosts configured with local server (e.g.,
/etc/resolv.conf) or learn the server via DHCP
• Client application
– Extract server name (e.g., from the URL)
– Do gethostbyname() to trigger resolver code
• Server application
– Extract client IP address from socket
– Optional gethostbyaddr() to translate into name 12
Example
root DNS server
Host at cis.poly.edu
wants IP address for
2
gaia.cs.umass.edu 3
TLD DNS server
4
local DNS server
dns.poly.edu 5
7 6
1 8
16
DNS Resource 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
www.ibm.com is really
• Type=NS servereast.backup2.ibm.com
– name is domain (e.g. foo.com) – value is canonical name
– value is hostname of
authoritative name server for •
Type=MX
this domain
– value is name of mailserver
associated with name
17
DNS Protocol
DNS protocol : query and reply messages, both with same message format
Message header
• Identification: 16 bit # for
query, reply to query uses
same #
• Flags:
– Query or reply
– Recursion desired
– Recursion available
– Reply is authoritative
18
Reliability
• DNS servers are replicated
– Name service available if at least one replica is up
– Queries can be load balanced between replicas
19
Inserting Resource Records into DNS
• Example: just created startup “FooBar”
• Register foobar.com at Network Solutions
– Provide registrar with names and IP addresses of your
authoritative name server (primary and secondary)
– Registrar inserts two RRs into the com TLD server:
(foobar.com, dns1.foobar.com, NS)
(dns1.foobar.com, 212.212.212.1, A)
20
Playing With Dig on UNIX
• Dig program
– Allows querying of DNS system
– Use flags to find name server (NS)
– Disable recursion so that operates one step at a time
unix> dig +norecurse @a.root-servers.net NS www.cs.princeton.edu
;; AUTHORITY SECTION:
edu. 2D IN NS L3.NSTLD.COM.
edu. 2D IN NS D3.NSTLD.COM.
edu. 2D IN NS A3.NSTLD.COM.
edu. 2D IN NS E3.NSTLD.COM.
edu. 2D IN NS C3.NSTLD.COM.
edu. 2D IN NS G3.NSTLD.COM.
edu. 2D IN NS M3.NSTLD.COM.
edu. 2D IN NS H3.NSTLD.COM. 21
DNS and the Web
22
DNS Query in Web Download
• User types or clicks on a URL
– E.g., http://www.cnn.com/2006/leadstory.html
24
When are DNS Queries Unnecessary?
• Browser is configured to use a proxy
– E.g., browser sends all HTTP requests through a proxy
– Then, the proxy takes care of issuing the DNS request
25
Web Server Replicas
• Popular Web sites can be easily overloaded
– Web site often runs on multiple server machines
Internet
26
Directing Web Clients to Replicas
• Simple approach: different names
– www1.cnn.com, www2.cnn.com, www3.cnn.com
– But, this requires users to select specific replicas
27
Clever Load Balancing Schemes
• Selecting the “best” IP address to return
– Based on server performance
– Based on geographic proximity
– Based on network load
–…
• Example policies
– Round-robin scheduling to balance server load
– U.S. queries get one address, Europe another
– Tracking the current load on each of the replicas
28
Challenge: What About DNS Caching?
• Problem: DNS caching
– What if performance properties change?
– Web clients still learning old “best” Web server
– … until the cached information expires