Wednesday, January 04, 2006

Solaris(TM) hostname resolution for aliase and multiple hostname

Hostnames are listed in the hosts database, which may be contained in the /etc/hosts and /etc/inet/ipnodes files, the Network Information Service (NIS) hosts map, the Internet domain name server, or a combination of these. Each host has one official name (the first name in the database entry), and optionally one or more nicknames. Either official hostnames or nicknames may be specified in hostname.

The hosts file is a local database that associates the names of hosts with their Internet Protocol (IP) addresses. The hosts file can be used in conjunction with, or instead of, other hosts databases, including the Domain Name System (DNS), the NIS hosts map, the NIS+ hosts table, or information from an LDAP server. Programs use library interfaces to access information in the hosts file.

The hosts file has one entry for each IP address of each host. If a host has more than one IP address, it will have one entry for each, on consecutive lines. The format of each line is:

IP-address official-host-name nicknames . . .

Items are separated by any number of SPACE and/or TAB characters. The first item on a line is the host's IP address. The second entry is the host's official name. Subsequent entries on the same line are alternative names for the same machine, or “nicknames.” Nicknames are optional.

For a host with more than one IP address, consecutive entries for these addresses may contain the same or differing nicknames. Different nicknames are useful for assigning distinct names to different addresses.

A call to gethostbyname(3NSL) returns a hostent structure containing the union of all addresses and nicknames from each line containing a matching official name or nickname

Important thing to know the order of the reolved by nsswitch.conf

The operating system uses a number of databases of information about hosts, ipnodes, users (passwd and shadow), and groups. Data for these can come from a variety of sources: hostnames and host addresses, for example, can be found in /etc/hosts, NIS, NIS+, LDAP, or DNS. Zero or more sources may be used for each database; the sources and their lookup order are specified in the /etc/nsswitch.conf file.

resolve.conf is specific to DNS only
The resolver is a set of routines that provide access to the Internet Domain Name System.

In summary, (1) add ip and hostname or alias in the /etc/host file
(2) check nsswitch.conf has right order to lookup name
under swan, files nis instead of nis files
(3) resolv.conf only for DNS cases

No comments: