Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Topics: –DNS system –Gathering machine information How to find out the machines ip address, name, OS, version, etc."— Presentation transcript:

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

2 Name/Address conversion: –The mapping between hostnames and IP addresses is done by the domain name system (DNS) –domain name system: A hierarchical, domain-based naming scheme and a distributed database system Hierarchical naming scheme –name space partitioned in subdomains. –Top level of domains:.com.edu.gov.mil.org.net.cn.us.jp.nl –Each domain can have subdomains –Simple name.vs. fully qualified domain(absolute) name Distributed the delegation of naming authority –Each domain has the authority to allow names within that domain. –naming follows organization boundary not physical network boundary.

3 Root DNS Servers com DNS servers org DNS serversedu DNS servers poly.edu DNS servers umass.edu DNS servers yahoo.com DNS servers amazon.com DNS servers pbs.org DNS servers

4 requesting host cis.poly.edu gaia.cs.umass.edu root DNS server local DNS server dns.poly.edu 1 2 3 4 5 6 authoritative DNS server dns.cs.umass.edu 7 8 TLD DNS server Iterative Queries iterated query: contacted server replies with name of server to contact “I don’t know this name, but ask this server”

5 requesting host cis.poly.edu gaia.cs.umass.edu root DNS server local DNS server dns.poly.edu 1 2 4 5 6 authoritative DNS server dns.cs.umass.edu 7 8 TLD DNS server 3 Recursive queries recursive query: puts burden of name resolution on contacted name server heavy load?

6 –Domain name system. Each server keeps resource records (RRs) –Format: (domain_name, time to live, class, type, value) –IP address, mail exchange, canonical name, host description, other information Some relevant RR types: –A : maps a hostname to an IPv4 address –AAAA: maps a hostname to an IPv6 address –PTR: pointer records, map IP addresses to hostnames –MX: mail exchanger for a host –CNAME: canonical name. Used to assign a CNAME records for common services.

7 Example: Aix IN A 192.168.42.2 IN AAAA 3ffe:b80:1f8d:2:204:acff:fe17:bf38 IN MX 5 aix.unpbook.com. IN MX 10 mailhost.unpbook.com. Aix-4 IN A 192.168.42.2 ftp IN CNAME linux.unpbook.com www IN CNAME linux.unpbook.com

8 –The system calls that uses the DNS system: gethostbyname, gethostbyaddr –gethostbyname: query on A records; #include struct hostent *gethostbyname(const char *hostname) struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char **h_addr_list; };

9 #include struct hostend *gethostbyaddr(const char *addr, size_t len;int family) –addr is actually a pointer to an in_addr structure –Len = 4 for IPv4 and 16 for IPv6 –This function queries a the PTR records. –See example1.c and example2.c for the use of the two functions. –Notice that these system calls incur communications, you can observe this in example1a.c

10 Older Gethostbyname and getaddrbyname are not reentrant functions. Not thread safe and may have problem using in signal handlers, or anything that have concurrency. Why? static struct hostent hosts; struct hostent *gethostbyname2(…) { /* call DNS function for A or AAAA query */ /* fill in host structure */ return (&host); } Struct hostent * gethostbyaddr { /* call DNS function for PTR query in in-addr.arpa domain */ /* fill in host structure */ return(&host); }

11 Many other functions are not reentrant (can cause errors in code with signals or threads). –E.g. malloc, inet_ntoa –Newer systems have thread-safe implementations.

12 –Other functions to obtain system related information: To get the name of the host: –Uname: name, os, hardware of the machine –Gethostname #include int uname (struct utsname *name) Struct utsname { char sysname[_UTS_NAMESIZE]; char nodename[_UTS_NODESIZE]; char release[_UTS_NAMESIZE]; char version[_UTS_NAMESIZE]; char machine[_UTS_NAMESIZE]; } See example3.c

13 –Other functions to get system information: Get service information: not querying the DNS, but a system specific file: e.g. /etc/services –Getservbyname –Getservbyport #include Struct servent *getservbyname(const char *servname, const char *protoname); Struct servent *getservbyport(int port, const char*protname); Struct servent { char *s_name; char** s_aliases; int s_port; char *s_proto; } See example4.c and example5.c

14 –Other functions to get other network information: Host, service, network and protocols Getxxxent, setxxxent, endxxxend –Xxx = host, net, proto, serv These functions manipulate the files (database) on the local machine: –/etc/hosts hostent –/etc/networks netent –/etc/protocols protoent –/etc/services servent

15 –How to get cpu information and memory information of the current machine? –See example6.c


Download ppt "Topics: –DNS system –Gathering machine information How to find out the machines ip address, name, OS, version, etc."

Similar presentations


Ads by Google