Download presentation
Presentation is loading. Please wait.
Published byMichael Arnold Modified over 9 years ago
1
Lecture 10 Doman Name System CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger and Kurose & Ross
2
Hostnames People: many identifiers: SSN, name, passport # Internet hosts, routers: IP address (32/128 bit) - used for addressing datagrams “name”, e.g., ww.yahoo.com - used by humans http://www.youtube.com/watch?v=9ilYrY9iBhk http://www.youtube.com/watch?v=9ilYrY9iBhk IP Addresses are great for computers IP address includes information used for routing. IP addresses are tough for humans to remember. IP addresses are impossible to guess. ever guessed at the name of a WWW site? DNS 2
3
Domain Name System The domain name system is usually used to translate a host name into an IP address. Domain names comprise a hierarchy so that names are unique, yet easy to remember. distributed database implemented in hierarchy of many name servers hosts, routers, communicate with name servers to resolve names (address/name translation) DNS 3
4
Host name structure Each host name is made up of a sequence of labels separated by periods. Each label can be up to 63 characters The total name can be at most 255 characters. Examples: whitehouse.gov barney.the.purple.dinosaur.com cnl.cse.unr.edu DNS 4
5
Domain Name The domain name for a host is the sequence of labels that lead from the host (leaf node in the naming tree) to the top of the worldwide naming tree. A domain is a subtree of the worldwide naming tree. DNS 5 Root DNS Servers com DNS servers org DNS serversedu DNS servers unr.edu DNS servers dri.edu DNS servers yahoo.com DNS servers amazon.com DNS servers pbs.org DNS servers
6
DNS services hostname to IP address translation host aliasing Canonical, alias names mail server aliasing load distribution replicated Web servers: set of IP addresses for one canonical name Why not centralize DNS? single point of failure traffic volume distant centralized database maintenance DNS 6 doesn’t scale!
7
Distributed, Hierarchical Database Client wants IP for www.unr.edu; 1 st approx: client queries a root server to find edu DNS server client queries edu DNS server to get unr.edu DNS server client queries unr.edu DNS server to get IP address for www.unr.edu DNS 7
8
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 DNS 8 13 root name servers worldwide b USC-ISI Marina del Rey, CA l ICANN Los Angeles, CA e NASA Mt View, CA f Internet Software C. Palo Alto, CA (and 36 other locations) i Autonomica, Stockholm (plus 28 other locations) k RIPE London (also 16 other locations) m WIDE Tokyo (also Seoul, Paris, SF) a Verisign, Dulles, VA c Cogent, Herndon, VA (also LA) d U Maryland College Park, MD g US DoD Vienna, VA h ARL Aberdeen, MD j Verisign, ( 21 locations)
9
Top-Level Domain Servers responsible for com, org, net, edu, gov, … Network Solutions maintains servers for com TLD Educause for edu TLD Countries each have a top level domain 2 letter domain name uk, fr, ca, jp, … New top level domains include.aero.biz.coop.info.name.pro DNS 9
10
Authoritative Servers organization’s DNS servers, providing authoritative hostname to IP mappings for organization’s servers (e.g., Web, mail). The organization that owns a domain name is responsible for running a DNS server that can provide the mapping between hostnames within the domain to IP addresses. So - some machine run by UNR is responsible for everything within the rpi.edu domain. can be maintained by organization or service provider DNS 10
11
DNS Distributed Database There is one primary server for a domain, and typically a number of secondary servers containing replicated databases. UNR 11 rpi.edu DNS DB rpi.edu DNS DB unr.edu DNS DB Authoritative unr.edu DNS DB Replicas unr.edu DNS server
12
Local Name Server does not strictly belong to hierarchy each ISP (residential ISP, company, university) has one. also called “default name server” when host makes DNS query, query is sent to its local DNS server acts as proxy, forwards query into hierarchy DNS 12
13
DNS: caching and updating records once (any) name server learns mapping, it caches mapping cache entries timeout (disappear) after some time TLD servers typically cached in local name servers Thus root name servers not often visited DNS Cache poisoning attacks http://www.youtube.com/watch?v=1d1tUefYn4U http://www.youtube.com/watch?v=1d1tUefYn4U update/notify mechanisms under design by IETF RFC 2136 http://www.ietf.org/html.charters/dnsind-charter.html DNS 13
14
Inserting records into DNS example: new startup “Network Utopia” register name networkuptopia.com at DNS registrar (e.g., Network Solutions) provide names, IP addresses of authoritative name server (primary and secondary) registrar inserts two RRs into com TLD server: (networkutopia.com, dns1.networkutopia.com, NS) (dns1.networkutopia.com, 212.212.212.1, A) create authoritative server Type A record for www.networkuptopia.com; Type MX record for networkutopia.com DNS 14
16
DNS Clients A DNS client is called a resolver. A call to gethostbyname() is handled by a resolver (typically part of the client). Most Unix workstations have the file /etc/resolv.conf that contains the local domain and the addresses of DNS servers for that domain. DNS 16
17
/etc/resolv.conf search cse.unr.edu me.unr.edu engr.unr.edu ce.unr.edu it.unr.edu unr.edu nameserver 134.197.5.1 nameserver 134.197.6.1 DNS 17
18
nslookup nslookup is an interactive resolver that allows the user to communicate directly with a DNS server. nslookup is usually available on Unix workstations. dig and host are also DNS clients DNS 18
19
DNS Servers Servers handle requests for their domain directly. Servers handle requests for other domains by contacting remote DNS server(s). Servers cache external mappings. DNS 19
20
Server - Server Communication If a server is asked to provide the mapping for a host outside it’s domain (and the mapping is not in the server cache): The server finds a nameserver for the target domain. The server asks the nameserver to provide the host name to IP translation. To find the right nameserver, use DNS! DNS 20
21
DNS Data DNS databases contain more than just hostname-to-address records: Name server recordsNS Hostname aliases CNAME Mail ExchangersMX Host InformationHINFO DNS 21
22
Server Operation If a server has no clue about where to find the address for a hostname, ask the root server. The root server will tell you what nameserver to contact. A request may get forwarded a few times. DNS 22
23
DNS name resolution example Host at cse.unr.edu wants IP address for rec.dri.edu DNS 23 requesting host cse.unr.edu rec.dri.edu root DNS server local DNS server ns1.unr.edu 1 2 3 4 5 6 authoritative DNS server dns.dri.edu 7 8 TLD DNS server iterated query: rcontacted server replies with name of server to contact r“I don’t know this name, but ask this server”
24
Recursion A request can indicate that recursion is desired - this tells the server to find out the answer (possibly by contacting other servers). If recursion is not requested - the response may be a list of other name servers to contact. DNS 24
25
DNS name resolution example DNS 25 requesting host cse.unr.edu rec.dri.edu root DNS server local DNS server ns1.unr.edu 1 2 4 5 6 authoritative DNS server dns.dri.edu 7 8 TLD DNS server 3 recursive query: rputs burden of name resolution on contacted name server rheavy load?
26
UDP & TCP Both UDP and TCP are used: TCP for transfers of entire database to secondary servers (replication) UDP for lookups If more than 512 bytes in response requestor resubmits request using TCP. DNS 26
27
DNS records DNS: distributed db storing resource records (RR) DNS 27 RR format: (name, value, type, ttl) rType=A name is hostname value is IP address rType=CNAME name is alias name for some “canonical” (the real) name www.ibm.com is really servereast.backup2.ibm.com value is canonical name rType=MX value is name of mailserver associated with name rType=NS name is domain (e.g. foo.com) value is hostname of authoritative name server for this domain rType=AAA
28
DNS protocol, messages DNS protocol : query and reply messages, both with same message format DNS 28 ridentification: 16 bit # for query, reply to query uses same # rflags: QR: Query=0, Response=1 AA: Authoritative Answer TC: response truncated (> 512 bytes) RD: recursion desired RA: recursion available rcode: return code Response
29
DNS protocol, messages DNS 29 Name, type fields for a query RRs in response to query records for authoritative servers additional “helpful” info that may be used
30
Name to Address Conversion There is a library of functions that act as DNS client (resolver). you don’t need to write DNS client code to use DNS! With some OSs you need to explicitly link with the DNS resolver library: -lnsl ( nsl is “Name Server Library”) DNS 30 Suns (Solaris) need this!
31
DNS library functions gethostbyname gethostbyaddr gethostbyname2 DNS 31 IPV6!
32
gethostbyname Return IP addresses of a host struct hostent *gethostbyname( const char *hostname); struct hostent is defined in netdb.h: All the IP addresses returned via the hostent are in network byte order! DNS 32
33
hostent picture h_name h_aliases h_addrtype h_length h_addr_list DNS 33 alias 1 alias 2 null Official Name IP address 1 IP address 2 null
34
Which Address? On success, gethostbyname returns the address of a hostent that has been created. has an array of ptrs to IP addresses Usually use the first one: #define h_addr h_addr_list[0] DNS 34
35
gethostbyname and errors On error gethostbyname return null. Gethostbyname sets the global variable h_errno to indicate the exact error: HOST_NOT_FOUND TRY_AGAIN NO_RECOVERY NO_DATA NO_ADDRESS DNS 35 All defined in netdb.h
36
Getting at the address: char **h_addr_list; h = gethostbyname("joe.com"); sockaddr.sin_addr.s_addr = *(h->h_addr_list[0]); This won't work!!!! h_addr_list[0] is a char* ! DNS 36
37
Using memcpy You can copy the 4 bytes (IPv4) directly: h = gethostbyname("joe.com"); memcpy(&sockaddr.sin_addr, h->h_addr_list[0], sizeof(struct in_addr)); DNS 37
38
gethostbyaddr Return hostname corresponding to an IP. struct hostent *gethostbyaddr( const char *addr size_t len, int family); DNS 38 AF_INET (could be AF_INET6) sizeof(struct in_addr)
39
Some other functions uname get hostname of local host getservbyname get port number for a named service getservbyaddr get name for service associated with a port number DNS 39
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.