Elementary Name and Address Conversions



Similar documents
Elementary Name and Address. Conversions

Hostnames. HOSTS.TXT was a bottleneck. Once there was HOSTS.TXT. CSCE515 Computer Network Programming. Hierarchical Organization of DNS

Domain Name System (1)! gethostbyname (2)! gethostbyaddr (2)!

DNS Domain Name System

Name and Address Conversions

CS640: Computer Networks. Naming /ETC/HOSTS

Porting applications & DNS issues. socket interface extensions for IPv6. Eva M. Castro. ecastro@dit.upm.es. dit. Porting applications & DNS issues UPM

Copyright

ECE 4321 Computer Networks. Network Programming

Motivation. Domain Name System (DNS) Flat Namespace. Hierarchical Namespace

Socket Programming. Kameswari Chebrolu Dept. of Electrical Engineering, IIT Kanpur

DNS. The Root Name Servers. DNS Hierarchy. Computer System Security and Management SMD139. Root name server. .se name server. .

- Domain Name System -

DNS : Domain Name System

Lecture 2 CS An example of a middleware service: DNS Domain Name System

DNS. Computer Networks. Seminar 12

DNS. Computer networks - Administration 1DV202. fredag 30 mars 12

Network Programming. Chapter The Client-Server Programming Model

Concurrent Server Design Alternatives

TCP/IP - Socket Programming

Domain Name System (DNS) Fundamentals

My Services Online Service Support. User Guide for DNS and NTP services

Applications and Services. DNS (Domain Name System)

Domain Name System :49:44 UTC Citrix Systems, Inc. All rights reserved. Terms of Use Trademarks Privacy Statement

A Client Server Transaction. Introduction to Computer Systems /18 243, fall th Lecture, Nov. 3 rd

Use Domain Name System and IP Version 6

The Domain Name System

Domain Name System (DNS) Session-1: Fundamentals. Ayitey Bulley

Generalised Socket Addresses for Unix Squeak

Socket Programming in C/C++

UNIX Sockets. COS 461 Precept 1

Writing Client/Server Programs in C Using Sockets (A Tutorial) Part I. Session Greg Granger grgran@sas. sas.com. SAS/C & C++ Support

BSD Sockets Interface Programmer s Guide

DNS & IPv6. Agenda 4/14/2009. MENOG4, 8-9 April Raed Al-Fayez SaudiNIC CITC rfayez@citc.gov.sa, DNS & IPv6.

DNS - Domain Name System

Writing a C-based Client/Server

Motivation. Users can t remember IP addresses. Implemented by library functions & servers. - Need to map symbolic names (

Software changes for Website and Application IPv6 Readiness

Agenda. Network Services. Domain Names. Domain Name. Domain Names Domain Name System Internationalized Domain Names. Domain Names & DNS

IPv6 Support in the DNS. Workshop Name Workshop Location, Date

Internet-Praktikum I Lab 3: DNS

Domain Name Servers. Domain Types WWW host names. Internet Names. COMP476 Networked Computer Systems. Domain Name Servers

Network Programming with Sockets. Anatomy of an Internet Connection

API of DNS hosting. For DNS-master and Secondary services Table of contents

Deploying & Configuring a DNS Server on OpenServer 6 or UnixWare 7. Kirk Farquhar

How to Add Domains and DNS Records

How To - Configure Virtual Host using FQDN How To Configure Virtual Host using FQDN

How to Configure the Windows DNS Server

First Workshop on Open Source and Internet Technology for Scientific Environment: with case studies from Environmental Monitoring

Using Webmin and Bind9 to Setup DNS Sever on Linux

DNS. Outline. What is DNS? How resolve name IP addr? DNS (Domain Name Service) is primarily used to. usable addresses, e.g., IP addresses.

File transfer and login using IPv6, plus What to do when things don t work

Part 5 DNS Security. SAST01 An Introduction to Information Security Martin Hell Department of Electrical and Information Technology

Fasthosts Internet Parallels Plesk 10 Manual

DNS (Domain Name System) is the system & protocol that translates domain names to IP addresses.

Installing and Setting up Microsoft DNS Server

THE DOMAIN NAME SYSTEM DNS

IP addresses have hierarchy (network & subnet) Internet names (FQDNs) also have hierarchy. and of course there can be sub-sub-!!

Lesson 13: DNS Security. Javier Osuna GMV Head of Security and Process Consulting Division

3. The Domain Name Service

Forouzan: Chapter 17. Domain Name System (DNS)

IPv6 support in the DNS

Application Protocols in the TCP/IP Reference Model

Socket Programming. Srinidhi Varadarajan

CSE 333 SECTION 6. Networking and sockets

Tutorial on Socket Programming

How-to: DNS Enumeration

Domain Name System (DNS)

Application Protocols in the TCP/IP Reference Model. Application Protocols in the TCP/IP Reference Model. DNS - Concept. DNS - Domain Name System

The Domain Name System (DNS)

The Domain Name System

An Advanced 4.4BSD Interprocess Communication Tutorial

Programming With Sockets 2

Clear and Present Danger Increase in Number of DNS AAAA Queries

The Application Layer: DNS

Understand Names Resolution

CS3250 Distributed Systems

Windows Socket Programming & IPv6 Translation Middleware

KB Windows 2000 DNS Event Messages 1 Through 1614

Domain Name System. DNS is an example of a large scale client-server application. Copyright 2014 Jim Martin

OpenSRS Service DNS Configuration Guide

416 Distributed Systems. Feb 24, 2016 DNS and CDNs

Networking Domain Name System

Networking Domain Name System

Domain Name System DNS

The Domain Name System

HTG XROADS NETWORKS. Network Appliance How To Guide: EdgeDNS. How To Guide

RPG Does TCP/IP (Socket Progamming in RPG IV)

Domain Name System (DNS) RFC 1034 RFC

Inbound Load Balance. User Manual

Talk-101 User Guide. DNSGate

Network Layers. CSC358 - Introduction to Computer Networks

NetIQ Advanced Authentication Framework - MacOS Client

Client / Server Programming with TCP/IP Sockets

Transcription:

Elementary Name and Address Conversions Domain name system gethostbyname Function RES_USE_INET6 resolver option gethostbyname2 Function and IPv6 support gethostbyaddr Function uname and gethostname Functions getservbyname and getservbyport Functions Other networking information 1

Domain Name System Entries in DNS: resource records (RRs) for a host A record: maps a hostname to a 32-bit IPv4 addr AAAA (quad A) record: maps to a 128-bit IPv6 addr PTR record: maps IP addr to hostname MX record: specifies a mail exchanger of the host CNAME record: assigns canonical name for common services e.g. solaris IN A 206.62.226.33 IN AAAA 5f1b:df00:ce3e:e200:0020:0800:2078:e3e3 IN MX 5 solaris.kohala.com IN MX 10 mailhost.kohala.com IN PTR 33.226.62.206.in-addr.arpa www IN CNAME bsdi.kohala.com 2

DNS: Application, Resolver, Name Servers application application code UDP call return request resolver local other code name name UDP server servers reply resolver configuration files resolver functions: gethostbyname/gethostbyaddr name server: BIND (Berkeley Internet Name Domain) static hosts files (DNS alternatives): /etc/hosts resolver configuration file (specifies name server IPs): /etc/resolv.conf 3

gethostbyname Function performs a DNS query for an A record or a AAAA record #include <netdb.h> struct hostent *gethostbyname (const char *hostname); returns: nonnull pointer if OK, NULL on error with h_errno set struct hostent { char *h_name; /* official (canonical) name of host */ char **h_aliases; /* ptr to array of ptrs to alias names */ int h_addrtype; /* host addr type: AF_INET or AF_INET6 */ int h_length; /* length of address: 4 or 16 */ char **h_addr_list; /* ptr to array of ptrs with IPv4/IPv6 addrs */ }; #define h_addr h_addr_list[0] /* first address in list */ 4

hostent Structure Returned by gethostbyname hostent { } h_name canonical hostname \0 h_aliases h_addrtype AF_INET/6 h_length 4/16 h_addr_list NULL NULL alias #1 \0 alias #2 \0 in/6_addr { } IP addr #1 in/6_addr { } IP addr #2 in/6_addr { } IP addr #3 5

Call gethostbyname and Print Returned Info (See program in Figure 9.4) 6

RES_USE_INET6 Resolver Option Per-application: call res_init #include <resolv.h> res_init ( ); _res.options = RES_USE_INET6 Per-user: set environment variable RES_OPTIONS export RES_OPTIONS=inet6 Per-system: update resolver configuration file options inet6 (in /etc/resolv.conf) For a host without a AAAA record, IPv4- mapped IPv6 addresses are returned. 7

gethostbyname2 Function and IPv6 Support #include <netdb.h> struct hostent *gethostbyname2 (const char *hostname, int family); returns: nonnull pointer if ok, NULL on error with h_errno set RES_USE_INET6 option off on gethostbyname A record AAAA record (host) or A record returning IPv4-mapped IPv6 addr gethostbyname2 A record A record returning (host, AF_INET) IPv4-mapped IPv6 addr gethostbyname2 AAAA record AAAA record (host, AF_INET6) 8

gethostbyaddr Function binary IP address to hostent structure #include <netdb.h> struct hostent *gethostbyaddr (const char *addr, size_t len, int family); returns: nonnull pointer if OK, NULL on error with h_errno set addr argument: a pointer to an in_addr or in6_addr structure h_name in hostent: canonical hostname gethostbyaddr: queries a DNS name server for a PTR record in the in-addr.arpa domain for IPv4 or a PTR record in the ip6.int domain for IPv6. 9

uname and gethostname Functions #include <sys/utsname.h> int uname (struct utsname *name); returns: nonnegative value if OK, -1 on error struct utsname { char sysname[_uts_namesize]; /* name of OS */ char nodename[_uts_nodesize]; /* name of this node */ char release[_uts_namesize]; /* OS release level */ char version[_uts_namesize]; /* OS version level */ char machine[_uts_namesize]; /* hardware type */ #include <unistd.h> int gethostname (char *name, size_t namelen); returns: 0 if OK, -1 on error 10

getservbyname and getservbyport Functions #include <netdb.h> struct servent *getservbyname (const char *servname, const char *protoname); returns: nonnull pointer if OK, NULL on error struct servent *getservbyport (int port, const char *protoname); returns: nonnull pointer if OK, NULL on error struct servent { char *s_name; /* official service name */ char **s_aliases; /*alias list */ int s_port; /* port number, network-byte order */ char *s_proto; /* protocol, TCP or UDP, to use */ Mapping from name to port number: in /etc/services Services that support multiple protocols often use the same TCP and UDP port number. But it s not always true: shell 514/tcp syslog 514/udp 11

daytime Client using gethostbyname and getservbyname (see Figure 9.8) Call gethostbyname and getservbyname Try each server address Call connect Check for failure Read server s reply 12

Other Networking Info Four types of info: hosts (gethostbyname, gethostbyaddr) through DNS or /etc/hosts, hostent structure networks (getnetbyname, getnetbyaddr) through DNS or /etc/networks, netent structure protocols (getprotobyname, getprotobynumber) through /etc/protocols, protoent structure services (getservbyname, getservbyport) through /etc/servies, servent structure 13