cse 123b communications software · may 9, 2004 cse 123b – lecture 10 -- dns 5 more socket...

38
CSE 123b CSE 123b Communications Software Communications Software Spring 2004 Spring 2004 Lecture 10: Domain Name System (DNS) Lecture 10: Domain Name System (DNS) Stefan Savage Stefan Savage Some slides courtesy David Wetherall & Srini Seshan

Upload: others

Post on 22-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

CSE 123bCSE 123bCommunications SoftwareCommunications Software

Spring 2004Spring 2004

Lecture 10: Domain Name System (DNS)Lecture 10: Domain Name System (DNS)

Stefan SavageStefan Savage

Some slides courtesy David Wetherall& Srini Seshan

Page 2: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 2

Topic #1: HomeworkTopic #1: Homework

Bring your homeworkup front

Page 3: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 3

Topic #2: MidtermTopic #2: Midterm

Quick Survey

Page 4: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 4

Topic #3: ProjectTopic #3: ProjectYou have started right?

Unix network programming review◆ Cover somewhat in chapter #1 of the book◆ http://www.ecst.csuchico.edu/~beej/guide/net/html/ also not

bad◆ Quick review – simple client-side APIs:

» Socket data structure: just like a file descriptor» Create with int socket (int domain, int type, int protocol)

domain = PF_INET (defined in sys/socket.h)type = SOCK_STREAM for TCP or SOCK_DGRAM for UDPprotocol = IPPROTO_TCP for TCP or IPPROTO_UDP for UDP (can also just use 0 and let it pick)

Page 5: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 5

More socket programmingMore socket programmingIf using TCP then

◆ Connect to other host using int connect(int socket, struct sockaddr *address, intaddr_len) -- only tricky part is address structure

◆ Send and receive usingsend(int socket, char *buffer, int buf_len, int flags)recv(int socket, char *buffer, int buf_len, int flags)

If using UDP then send and receive using:◆ int sendto(int socket, char *buffer, int len, unsigned in

flags, struct sockaddr *toaddr, int tolen)◆ int recvfrom(int socket, char *buffer, int len, unsigned int

flags, struct sockaddr *fromaddr, int fromlen)

Page 6: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 6

Overview for todayOverview for todayWhat is naming about?

How Domain Naming System (DNS) works◆ Namespace◆ Data distribution◆ Request/response protocol◆ Caching◆ Bootstraping

Experience with DNS and new DNS uses

Page 7: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 7

Names and AddressesNames and Addresses

Names are identifiers for objects/services (high level)Addresses are locators for objects/services (low level)Resolution is the process of mapping name to address

Stefan SavageCSE Dept.University of California, San Diego

35¢

name

address

Page 8: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 8

Goals for a naming systemGoals for a naming systemHow do we locate resources?

◆ Machine name -> IP address◆ IP address -> Machine name

How do we scale to the wide area?◆ Global scope◆ Robustness◆ Consistency: additions, deletions, modifications◆ Performance/overhead◆ Different administrative authorities

Page 9: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 9

Internet HostnamesInternet HostnamesHostnames are human-readable identifiers for end-systems based on an administrative hierarchy

◆ risk64.ucsd.edu is my desktop machine

IP addresses are a fixed-length binary encoding for end-systems based on their position in the network

◆ 132.239.9.64 is risk64’s IP address

Page 10: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 10

Original Hostname SystemOriginal Hostname SystemWhen the Internet was really young …

Flat namespace◆ Simple (host, address) pairs

Centralized management◆ Updates via a single master file called HOSTS.TXT◆ Manually coordinated by the SRI’s Network Information

Center (NIC)◆ You ftp’d the file over each day

Resolution process◆ Look up hostname in the HOSTS.TXT file

Page 11: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 11

Scaling ProblemsScaling ProblemsCoordination

◆ Between all users to avoid conflicts

Inconsistencies◆ Between update and distribution of new version

Reliability◆ Single point of failure

Performance◆ Competition for centralized resources◆ Size of HOSTS.TXT

Page 12: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 12

Domain Name System (DNS)Domain Name System (DNS)Designed by Mockapetris and Dunlap in the mid 80s

◆ Distributed database

Namespace is hierarchical◆ Allows much better scaling of data structures◆ e.g., www.cs.ucsd.edu

Namespace is distributed◆ Decentralized administration and access◆ e.g. xxx.ucsd.edu is managed only by UCSD

Resolution is by query/response◆ With replicated servers for redundancy◆ With heavy use of caching for performance

Page 13: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 13

DNS DesignDNS DesignAdministrative hierarchy

◆ “.” as separator◆ Zone = contiguous section of name space with its own

database and administrative control» E.g., Complete tree, single node or subtree

Zones are created by convincing owner node to create/delegate a subzone

◆ E.g. cs.ucsd.edu could be a zone under ucsd.edu

Page 14: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 14

DNS HierarchyDNS Hierarchy

edu

cs

ucsd

auorgmilcom

ee

• “dot” is the root of the hierarchy• Top levels now controlled by ICANN (in theory)

• Lower level control is delegated• Usage governed by conventions• FQDN = Fully Qualified Domain Name

Page 15: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 15

DNS RecordsDNS RecordsDNS: distributed db storing resource records (RR)

Type=A◆ name is hostname◆ value is IP address

Type=NS◆ name is domain (e.g.

foo.com)◆ value is IP address of

authoritative name server for this domain

RR format: (name, value, type, ttl)

Type=CNAME◆ name is an alias name for some

“canonical” (the real) name◆ value is canonical name

Type=MX◆ value is hostname of mailserver

associated with name

Page 16: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 16

DNS DistributionDNS Distribution

One or more nameservers manage each zone◆ Primary nameserver updated manaually◆ Secondary nameservers updated using zone transfers performed

between nameservers (uses TCP)◆ Multiple nameservers provide redundancy

Client resolvers query nameservers for specified records◆ Multiple messages may be exchanged per DNS lookup to

navigate the name hierarchy

Page 17: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 17

Servers/Servers/ResolversResolversEach host has a resolver

◆ Typically a library that applications can link to, sometimes in kernel (e.g. Windows XP)

◆ Host resolvers hand-configured (e.g. /etc/resolv.conf) or frequently key information (e.g. IP address of local nameserver) is passed via DHCP

Name servers◆ Typically responsible for some zone (e.g. cs.ucsd.edu)◆ Local servers (also sometimes called caching servers)

» Do lookup of distant host names for local hosts» Typically answer queries about local zone

Page 18: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 18

Lookup MethodsLookup MethodsIterative

◆ Server responds with as much as it knows (iterative)Recursive

◆ Server goes out and searches for more info (recursive)◆ Only returns final answer or “not found”

Local server typically does recursiveRoot/distant server does iterative

Page 19: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 19

DNS Lookup ExampleDNS Lookup ExampleRecursive query:

Puts burden of name resolution on contacted name server

Iterative query:Contacted server replies with name of server to contact“I don’t know this name, but ask this server”

requesting hostsurf.eurecom.fr

gaia.cs.umass.edu

root name server

local name serverdns.eurecom.fr

1

2

34

5 6authoritative name server

dns.cs.umass.edu

intermediate name serverdns.umass.edu

7

8

iterated query

Page 20: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 20

DNS Message FormatDNS Message FormatIdentification

No. of Questions

No. of Authority RRs

Questions (variable number of answers)

Answers (variable number of resource records)

Authority (variable number of resource records)

Additional Info (variable number of resource records

Flags

No. of Answer RRs

No. of Additional RRsName, type fields for a query

RRs in response to query

Records for authoritative servers

Additional “helpful info that may be used

12 bytes

Page 21: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 21

DNS Header FieldsDNS Header FieldsIdentification field

◆ Used to match up request/response◆ How to pick id value?

Flags◆ 1-bit to mark query or response◆ 1-bit to mark authoritative or not◆ 1-bit to request recursive resolution◆ 1-bit to indicate support for recursive resolution

Page 22: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 22

CachingCachingServers and clients cache results of DNS lookups

◆ Cache partial results too (e.g., server for princeton.edu)◆ Greatly improves system performance; lookups the rare case

Cache using time-to-live (TTL) value from provider◆ Higher TTL means less traffic, lower TTL means less stale info

Negative caching is used too!◆ Errors can cause repeated queries for non-existent data

Page 23: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 23

Impact of cachingImpact of cachingDNS Lookup ExampleDNS Lookup Example

Client Local DNS server

root & eduDNS server

cmu.eduDNS server

www.cs.cmu.edu

NS cmu.eduwww.cs.cmu.edu

NS cs.cmu.edu

www=IPaddr

cs.cmu.eduDNS

server

Page 24: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 24

Impact of cachingImpact of cachingSubsequent Lookup Subsequent Lookup

Client Local DNS server

root & eduDNS server

cmu.eduDNS server

cs.cmu.eduDNS

server

ftp.cs.cmu.edu

ftp=IPaddr

ftp.cs.cmu.edu

Page 25: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 25

ReliabilityReliabilityDNS servers are replicated

◆ Name service available if at least one replica is up

UDP used for queries◆ Need reliability Why not TCP?◆ Try alternate servers on timeout

» How long a timeout?◆ Exponential backoff when retrying same server◆ Same identifier for all queries

» Don’t care which server responds

Page 26: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 26

Reverse Name LookupReverse Name Lookup128.2.206.138?

◆ Lookup 138.206.2.128.in-addr.arpa◆ Why is the address reversed?

What if there is a many to one mapping?◆ i.e. www.cs.ucsd.edu and www-cse.ucsd.edu are the same

machine◆ Reverse lookup should return primary name

Page 27: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 27

Mail AddressesMail AddressesMX records point to mail exchanger for a name

◆ E.g. mail.acm.org is MX for acm.org

Addition of MX record type proved to be a challenge◆ How to get mail programs to lookup MX record for mail

delivery?◆ Needed critical mass of such mailers

Page 28: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 28

DNS BootstrappingDNS BootstrappingNeed to know IP addresses of root servers before we can make any queries

Addresses for 13 root servers ([a-m].root-servers.net) handled via initial configuration (named.ca file or compiled into resolver)

Page 29: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 29

DNS: Root Name ServersDNS: Root Name ServersResponsible for “root” zoneApprox. dozen root name servers worldwide

◆ Currently {a-m}.root-servers.net

Local name servers contact root servers when they cannot resolve a name

◆ Configured with well-known root servers

Page 30: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 30

Building on the DNSBuilding on the DNS

Other naming designs leverage the DNS

Email: ◆ e.g., [email protected] is savage in the domain cs.ucsd.edu

Uniform Resource Locators (URLs) name for Web pages◆ e.g., http://www.cs.ucsd.edu/~savage/◆ Use domain name to identify a Web server◆ Use “/” separated string to name path to page (like files)

Page 31: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 31

Building on the DNSBuilding on the DNSLoad balancing of Internet services

◆ If a name -> IP address mapping is one to many then can use DNS for load balancing

◆ RR DNS: provide set of answers◆ Akamai/CDNs: provide different answer based on source

address of local server and load on replicated content

NearbyCache

Server

DNS serversfor akamai.com

client1

23456

Page 32: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 32

Future Evolution of the DNSFuture Evolution of the DNSDesign constrains us in two major ways that are increasingly less appropriate

Static host to IP mapping◆ What about mobility (Mobile IP) and dynamic address

assignment (DHCP)

Location-insensitive queries◆ What if I don’t care what server a Web page comes from, as

long as it’s the right page?◆ e.g., a yahoo page might be replicated

Page 33: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 33

DNS ExperienceDNS ExperienceOne of the greatest challenges seemed to be getting good name server implementations

◆ Developers were typically happy with “good enough” implementation

◆ Challenging, large scale, wide area distributed system» Like routing, but easier to have broken implementations that work

Common bugs◆ Poor static configuration (root server list)◆ Lack of exponential backoff◆ No centralized caching per site

» Each machine runs own caching local server

Page 34: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 34

Root ZoneRoot ZoneGeneric Top Level Domains (gTLD) = .com, .net, .org, etc…Country Code Top Level Domain (ccTLD) = .us, .ca, .fi, .uk, etc…Root server ({a-m}.root-servers.net) also used to cover gTLD domains

◆ Load on root servers was growing quickly!◆ Moving .com, .net, .org off root servers was clearly necessary

to reduce load done Aug 2000

Page 35: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 35

New New gTLDsgTLDs.info general info.biz businesses.aero air-transport industry .coop business cooperatives.name individuals.pro accountants, lawyers, and physicians.museum museumsOnly new one actives so far = .info, .biz

Page 36: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 36

New RegistrarsNew RegistrarsNetwork Solutions (NSI) used to handle all registrations, root servers, etc…

◆ Clearly not the democratic way◆ Large number of registrars that can create new domains

However NSI still handle root servers

Page 37: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 37

Key ConceptsKey ConceptsThe design of names, addresses and resolution has a significant impact on system capabilities

Hierarchy, decentralization and caching allow the DNS to scale

◆ These are general techniques!

Page 38: CSE 123b Communications Software · May 9, 2004 CSE 123b – Lecture 10 -- DNS 5 More socket programming zIf using TCP then Connect to other host using int connect(int socket, struct

May 9, 2004 CSE 123b – Lecture 10 -- DNS 38

For next time…For next time…HTTP: Read 9.2.2