Menu

Networks II: Homework


You must print this sheet out and write/type answers on it!

  1. Do an nslookup on the Unix lab machine you usually use, what is:
    a. it's name as you entered it
    
    
    b. it's canonical name
    
    
    c. it's IP address
    	    
  2. Look at the file /etc/resolv.conf. You see the IP addresses of several name servers --- these are the nameservers your machine will contact to answer nslookup queries. Use nslookup to get the names for each of these IP addresses, and list each IP address / name pair.
    
    
    
    	    
  3. The gethostbyname is considered poor form now. Instead, getipnodebyname should be used. Show how in the code for sym2ip shown below would be modified to use getipnodebyname in place of the call H = gethostbyname(argv[1]);.
    
    
    	    
  4. struct	hostent {
    	char	*h_name;	/* official name of host */
    	char	**h_aliases;	/* alias list */
    	int	h_addrtype;	/* host address type */
    	int	h_length;	/* length of address */
    	char	**h_addr_list;	/* list of addresses from name server */  ← the raw addresses, not dotted quads!
                                    Just to muddy things up a bit:
                                    although h_addr_list has type char**,
                                    they really mean void**, in that 
                                    an entry h_addr_list[0], for
                                    instance, could point to any kind of
                                    object.  In fact, for IPv4, it's
                                    really pointing to an 'unsigned int'.
                                    So ... you must cast that pointer to
                                    an (unsigned int*) to use it right.
    
    };
    	    
    Suppose we have the following deifnitions:
    struct hostent *p, A;
    	    
    What are the types of the following expressions: