Netprog: DNS and name lookups1 Address Conversion Functions and The Domain Name System Refs: Chapter 9 RFC 1034 RFC 1035.

Slides:



Advertisements
Similar presentations
Topics: –DNS system –Gathering machine information How to find out the machines ip address, name, OS, version, etc.
Advertisements

The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.
Lecture 10 Doman Name System CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger and Kurose & Ross.
Name and Address Conversions© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid.
20101 The Application Layer Domain Name System Chapter 7.
CS 311 – Lecture 19 Outline Internet Sockets – gethostname utility – struct hostent – inet_addr – Machine byte to Network byte order translation and vice.
Domain Name System: DNS
Shivkumar Kalyanaraman Rensselaer Polytechnic Institute 1 Domain Name System (DNS) Shivkumar Kalyanaraman Rensselaer Polytechnic Institute
CPSC 441: DNS1 Instructor: Anirban Mahanti Office: ICT Class Location: ICT 121 Lectures: MWF 12:00 – 12:50 Notes derived.
1 DNS,NFS & RPC Rizwan Rehman, CCS, DU. Netprog: DNS and name lookups 2 Hostnames IP Addresses are great for computers –IP address includes information.
Domain Name System ( DNS )  DNS is the system that provides name to address mapping for the internet.
TCP/IP Protocol Suite 1 Chapter 17 Upon completion you will be able to: Domain Name System: DNS Understand how the DNS is organized Know the domains in.
Netprog 2002 DNS1 Application-layer Protocols Based on Notes by D. Hollinger Based on UNIX Network Programming, Stevens, Chapter 9 Also Java Network Programming.
DNS. Outline r Domain Name System r DNS Hierarchy r Resolution.
1 Domain Name System (DNS) Professor Hui Zhang. 2 Hui Zhang Names, Addresses, Mapping  Binding Names to Objects  ARP: mapping between layer 2 address.
CS640: Computer Networks Aditya Akella Lecture 17 Naming and the DNS.
USER DATAGRAM PROTOCOL (UDP) Prof. Crista Lopes. What is UDP ?  an unreliable transport protocol that can be used in the Internet.  an alternative to.
NET0183 Networks and Communications Lecture 25 DNS Domain Name System 8/25/20091 NET0183 Networks and Communications by Dr Andy Brooks.
CS 4396 Computer Networks Lab
1 Domain Name System (DNS). 2 DNS: Domain Name System Internet hosts: – IP address (32 bit) - used for addressing datagrams – “name”, e.g.,
Domain Name System (DNS)
DNS Domain Name System. Hostnames  IP Addresses are great for computers – IP address includes information used for routing.  IP addresses are tough.
Lecture on DHCP, DNS & SNMPDebashis Saha Thursday, May 17, DHCP, DNS, SNMP Debashis Saha MIS Group, IIM Calcutta
Chapter 16 – DNS. DNS Domain Name Service This service allows client machines to resolve computer names (domain names) to IP addresses DNS works at the.
Computer Networks Mozafar Bag-Mohammadi Lecture 5 Naming and the DNS.
Domain Names System The Domain Name System (DNS) is a hierarchical distributed naming system for computers, services, or any resource connected to the.
Elementary Name and Address Conversions
DNS: Domain Name System
1 DNS: Domain Name System People: many identifiers: m SSN, name, Passport # Internet hosts, routers: m IP address (32 bit) - used for addressing datagrams.
Architecture of DNS CS 718 Activity 4 Submitted by Parag Abhyankar Anup S. Kunte
25.1 Chapter 25 Domain Name System Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
14 DNS : The Domain Name System. 14 Introduction - Problem Computers are used to work with numbers Humans are used to work with names ==> IP addresses.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2000 Network Protocols Chapter 25 (Data Communication & Networking Book): Domain Name System (DNS) 1.
Chapter 17 Domain Name System
25.1 Chapter 25 Domain Name System Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 29 Domain Name System (DNS) Allows users to reference computer names via symbolic names translates symbolic host names into associated IP addresses.
TCP/IP Protocol Suite 1 Chapter 17 Upon completion you will be able to: Domain Name System: DNS Understand how the DNS is organized Know the domains in.
October 8, 2015 University of Tulsa - Center for Information Security Microsoft Windows 2000 DNS October 8, 2015.
Domain Name System. CONTENTS Definitions. DNS Naming Structure. DNS Components. How DNS Servers work. DNS Organizations. Summary.
Netprog: DNS and name lookups1 Address Conversion Functions and The Domain Name System Refs: Chapter 9 RFC 1034 RFC 1035.
Internet and Intranet Protocols and Applications Lecture 5 Application Protocols: DNS February 20, 2002 Joseph Conron Computer Science Department New York.
1 Kyung Hee University Chapter 18 Domain Name System.
Domain Name System Refs: Chapter 9 RFC 1034 RFC 1035.
CPSC 441: DNS 1. DNS: Domain Name System Internet hosts: m IP address (32 bit) - used for addressing datagrams m “name”, e.g., - used by.
Elementary Name and Address Conversions
24. DNS Domain Name System address 1. Name server domain name IP address ftp.cs.mit.eduxx.xx.xx.xx 24.2 Mapping Domain Names To.
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 19 Domain Name System (DNS)
TELE 402 Lecture 6: Name and address conversions 1 Overview Last Lecture –Socket Options and elementary UDP sockets This Lecture –Name and address conversions.
Advanced UNIX programming Fall 2002 Instructor: Ashok Srinivasan Lecture 25 Acknowledgements: The syllabus and power point presentations are modified versions.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2000 Chapter 18 Domain Name System (DNS)
1. Internet hosts:  IP address (32 bit) - used for addressing datagrams  “name”, e.g., ww.yahoo.com - used by humans DNS: provides translation between.
TCP/IP Protocol Suite 1 Chapter 17 Upon completion you will be able to: Domain Name System: DNS Understand how the DNS is organized Know the domains in.
COMP 431 Internet Services & Protocols
Internet Naming Service: DNS* Chapter 5. The Name Space The name space is the structure of the DNS database –An inverted tree with the root node at the.
Domain Name System INTRODUCTION to Eng. Yasser Al-eimad
Domain Name System DPNM Lab. Seongho Cho
Domain Name System (DNS)
Networking Applications
Name and Address Conversions
Domain Name System: DNS
Chapter 9: Domain Name Servers
Name/Address conversion:
CS 3251: Computer Networking I Nick Feamster Spring 2013
CpSc 360: Distributed and Network Programming
Name and Address Conversions Part I
Domain Name System (DNS)
Application-layer Protocols
Domain Name System Refs: Chapter 9 RFC 1034 RFC 1035.
DNS : Domain Name System
Domain Name System: DNS
Presentation transcript:

Netprog: DNS and name lookups1 Address Conversion Functions and The Domain Name System Refs: Chapter 9 RFC 1034 RFC 1035

Netprog: DNS and name lookups2 Hostnames 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?

Netprog: DNS and name lookups3 The 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.

Netprog: DNS and name lookups4 DNS Hierarchy educomorgjp rpialbany

Netprog: DNS and name lookups5 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 –monica.cs.rpi.edu

Netprog: DNS and name lookups6 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.

Netprog: DNS and name lookups7 Top level domains edu, gov, com, net, org, mil, … Countries each have a top level domain (2 letter domain name). New top level domains include:.aero.biz.coop.info.name.pro

Netprog: DNS and name lookups8 DNS Organization Distributed Database –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 RPI is responsible for everything within the rpi.edu domain.

Netprog: DNS and name lookups9 rpi.edu DNS DB rpi.edu DNS DB DNS Distributed Database There is one primary server for a domain, and typically a number of secondary servers containing replicated databases. rpi.edu DNS DB Authoritative rpi.edu DNS DB Replicas rpi.edu DNS server

Netprog: DNS and name lookups10 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.

Netprog: DNS and name lookups11 /etc/resolv.conf domain rpi.edu

Netprog: DNS and name lookups12 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).

Netprog: DNS and name lookups13 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.

Netprog: DNS and name lookups14 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!

Netprog: DNS and name lookups15 DNS Data DNS databases contain more than just hostname-to-address records: –Name server recordsNS –Hostname aliases CNAME –Mail ExchangersMX –Host InformationHINFO

Netprog: DNS and name lookups16 The Root DNS Server The root server needs to know the address of 1st (and many 2nd) level domain nameservers. educomorgjp albany rpi

Netprog: DNS and name lookups17 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.

Netprog: DNS and name lookups18 DNS Message Format HEADER QUERIES Response RESOURCE RECORDS Response AUTHORITY RECORDS Response ADDITIONAL INFORMATION HEADER QUERIES Response RESOURCE RECORDS Response AUTHORITY RECORDS Response ADDITIONAL INFORMATION

Netprog: DNS and name lookups19 DNS Message Header query identifier flags # of questions # of RRs # of authority RRs # of additional RRs 16 bit fields Response }

Netprog: DNS and name lookups20 Message Flags QR: Query=0, Response=1 AA: Authoritative Answer TC: response truncated (> 512 bytes) RD: recursion desired RA: recursion available rcode: return code

Netprog: DNS and name lookups21 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.

Netprog: DNS and name lookups22 Question Format Name: domain name (or IP address) Query type (A, NS, MX, …) Query class (1 for IP)

Netprog: DNS and name lookups23 Response Resource Record Domain Name Response type Class (IP) Time to live (in seconds) Length of resource data Resource data

Netprog: DNS and name lookups24 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.

Netprog: DNS and name lookups25 Lots more This is not a complete description ! If interested - look at: –RFC 1034: DNS concepts and facilities. –RFC 1035: DNS implementation and protocol specification. –play with nslookup. –Look at code for BIND (DNS server code).

Netprog: DNS and name lookups26 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”) Suns (Solaris) need this!

Netprog: DNS and name lookups27 DNS library functions gethostbyname gethostbyaddr gethostbyname2 IPV6!

Netprog: DNS and name lookups28 gethostbyname struct hostent *gethostbyname( const char *hostname); struct hostent is defined in netdb.h: #include

Netprog: DNS and name lookups29 struct hostent struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char **h_addr_list; }; official name (canonical) other names AF_INET or AF_INET6 address length (4 or 16) array of ptrs to addresses

Netprog: DNS and name lookups30 hostent picture h_name h_aliases h_addrtype h_length h_addr_list Official Name alias 1 alias 2 null IP address 1 IP address 2 null

Netprog: DNS and name lookups31 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]

Netprog: DNS and name lookups32 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 All defined in netdb.h

Netprog: DNS and name lookups33 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* !

Netprog: DNS and name lookups34 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));

Netprog: DNS and name lookups35 Network Byte Order All the IP addresses returned via the hostent are in network byte order! Repeat after me: "Thank you gethostbyname !"

Netprog: DNS and name lookups36 gethostbyaddr struct hostent *gethostbyaddr( const char *addr size_t len, int family); AF_INET (could be AF_INET6) sizeof(struct in_addr)

Netprog: DNS and name lookups37 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