externally to whatever IN A entry you defined for the host name in its dns zone.
locally to whatever you want the hostname to resolve to.
to see how the resolver works, check out /etc/host.conf.
a default ubuntu host.conf is:
order hosts,bind
multi on
first line is the old style of saying "check /etc/hosts then query dns", second is the new style of saying the same thing.
suppose you have eth0:10.0.0.1, eth1:10.0.0.2, eth2:10.0.0.3, eth4:10.0.0.4 and a hostname of "phony" defined in /etc/hostname (talking ubuntu, other distros may use different config schemes here altho i doubt it)
you can have the following /etc/hosts entries:
10.0.0.1 phony
then phony will resolve to 10.0.0.1 for local services
if you have something like this in /etc/hosts:
127.0.0.1 phony
phony will resolve to 127.0.0.1
if you have no declaration of phony in /etc/hosts then resolver will query the dns caches defined in /etc/resolv.conf, using the "domain" and "search" setups to build a dns compliant record (host) name.
so if you want to control to what the hostname resolves to for your local services, define it in /etc/hosts.
quick note: the hostname is normally just a dns label (that is, no "."). the domain name for your machine is normally defined in /etc/domainname
You don't mention which brand of Linux you're using.
RedHat (and Centos, and perhaps even Fedora) uses the /etc/sysconfig/network file to determine the host's name. Then, using the host's name, it determines the IP address of the host using the normal naming system (as given in /etc/resolv.conf), which in practice means that you should have an IP-to-name mapping in /etc/hosts.
The IP addresses are associated to the NICs in /etc/sysconfig/network-scripts/ethX, where X is an integer (0, 1, 2, and 3 in your case).
externally to whatever IN A entry you defined for the host name in its dns zone.
locally to whatever you want the hostname to resolve to. to see how the resolver works, check out /etc/host.conf. a default ubuntu host.conf is:
first line is the old style of saying "check /etc/hosts then query dns", second is the new style of saying the same thing.
suppose you have eth0:10.0.0.1, eth1:10.0.0.2, eth2:10.0.0.3, eth4:10.0.0.4 and a hostname of "phony" defined in /etc/hostname (talking ubuntu, other distros may use different config schemes here altho i doubt it)
you can have the following /etc/hosts entries:
then phony will resolve to 10.0.0.1 for local services if you have something like this in /etc/hosts:
phony will resolve to 127.0.0.1
if you have no declaration of phony in /etc/hosts then resolver will query the dns caches defined in /etc/resolv.conf, using the "domain" and "search" setups to build a dns compliant record (host) name.
so if you want to control to what the hostname resolves to for your local services, define it in /etc/hosts.
quick note: the hostname is normally just a dns label (that is, no "."). the domain name for your machine is normally defined in /etc/domainname
You don't mention which brand of Linux you're using.
RedHat (and Centos, and perhaps even Fedora) uses the /etc/sysconfig/network file to determine the host's name. Then, using the host's name, it determines the IP address of the host using the normal naming system (as given in /etc/resolv.conf), which in practice means that you should have an IP-to-name mapping in /etc/hosts.
The IP addresses are associated to the NICs in /etc/sysconfig/network-scripts/ethX, where X is an integer (0, 1, 2, and 3 in your case).
See http://www.centos.org/docs/5/html/5.2/Deployment_Guide/s2-sysconfig-network.html and http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:Ch03:_Linux_Networking
...and http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-networkscripts.html