Presentation 1
Presentation 1
Presentation 1
The mechanism by which Internet software translates names to addresses and vice versa. an internet service that translates domain names into IP addresses. Because domain names are alphabetic, they're easier to remember. The Internet however, is really based on Ip addresses. Every time you use a domain name, therefore, a DNS service must translate the name into the corresponding IP address. For example, the domain name www.example.com might translate to198.105.232.4. The DNS system is, in fact, its own network. If one DNS server doesn't know how to translate a particular domain name, it asks another one, and so on, until the correct IP address is returned
gethostbyname:
#include <netdb.h> struct hostent *gethostbyname(char *name); These functions map back and forth between host names and IP addresses. For instance, if you have "www.google.com", you can use gethostbyname() to get its IP address and store it in a struct in_addr. gethostbyname() takes a string like "www.yahoo.com", and returns a struct hostent which contains tons of information, including the IP address. gethostbyname() functions are used to resolve host names and addresses in the domain name system or the local host's other resolver mechanisms (e.g., /etc/hosts lookup). They return a pointer to an object of type struct hostent, which describes an Internet Protocol host. The functions take the following arguments: name specifies the name of the host. For example: www.wikipedia.org addr specifies a pointer to a struct in_addr containing the address of the host. len specifies the length, in bytes, of addr. type specifies the address family type (e.g., AF_INET) of the host address. Returns non null pointer if ok, Null on error with h_errno set
Gethostbyname2()
When support for IPV6 was added to BIND 4.9.4,the function gethostbyname2()was added, which has two arguments, allowing us to specify the address family #include <netdb.h> Struct hostent *gethostbyname2(const char *hostname, int family); The return value is the same as with gethostbyname, a pointer to a hostent structure and this structure remains the same. The operation of gethostbyname2 () is : if the family argument is AF_INET, a query is made for A records. If unsuccessful, the function returns a null pointer. If successful, the type and size of the returned addresses depends on the new RES_USE_INET6 resolver option. If the option is not set, IPV4 addresses are returned and the h_length member of the hostent structure will be 4. if option is set IPV4-mapped IPV6 addresses are returned and h_length member of the hostent structure will be 16. if the family argument is AF_INET6, a query is made for AAAA records. If successful, IPV6 addresses are returned and the h_length member of the hostent structure will be 16,otherwise the function return a null pointer.
Gethostbyaddress()
The functonion gethostbyaddr() takes a binary IP address and tries to find the hostname corresponding to that address. This is the reverse of gethostbyname. #include<netdb.h> Struct hostent *gethostbyaddr(const char *addr, size_t_len, int family); This fucntion returns a pointer to the hostent structure. The addr argument is not a char* but is really a pointer to an in_addr or in6_addr structure containing the IPv4 or IPv6 address. Len is the size of this structure 4 for an IPv4 addresses, or 16 for an IPv6 address. The family argument is either AF_INET or AF_INET6. In terms of DNS, gethostbyaddr queries a name serve for a PTR record in the in_addr.arpa domain for an IPV4 address, or a PTR record in the ip6.int domain for an IPV6 addredd.
Uname function
The uname() function shall store information identifying the current system in the structure pointed by name. The uname command displays the name, node, version, release, and hardware type of the current UNIX operating system. By default only the system's name is displayed. The most common use of uname is to find out which system you are using. Many users set their shell prompt (PS1) to the name of their system. This is especially useful if you have access to multiple systems. In Linux the following options are supported: -a, --all print all information, in the following order, except omit -p and -i if unknown: -s, --kernel-name print the kernel name -n, --nodename print the network node hostname
-r, --kernel-release print the kernel release -v, --kernel-version print the kernel version -m, --machine print the machine hardware name -p, --processor print the processor type or "unknown" -i, --hardware-platform print the hardware platform or "unknown" -o, --operating-system print the operating system --help display this help and exit --version output version information and exit