1 / 15

Topics: DNS system Gathering machine information

Topics: DNS system Gathering machine information How to find out the machines ip address, name, OS, version, etc. Name/Address conversion: The mapping between hostnames and IP addresses is done by the domain name system (DNS) domain name system:

dalton
Download Presentation

Topics: DNS system Gathering machine information

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 org DNS servers edu DNS servers com DNS servers poly.edu DNS servers umass.edu DNS servers pbs.org DNS servers yahoo.com DNS servers amazon.com DNS servers DNS servers

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

  5. root DNS server 2 3 6 7 TLD DNS server 4 local DNS server dns.poly.edu 5 1 8 authoritative DNS server dns.cs.umass.edu requesting host cis.poly.edu gaia.cs.umass.edu 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 <netdb.h> 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 <netdb.h> 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 <sys/utsname.h> 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 <netdb.h> 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

More Related