Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Consider a machine having 4 eth ports running on it. Then to which eth port's ipaddress will the hostname resolve to?

Kindly guide me to some documentation to support your answers so that I could use them as proof in my project.


share|improve this question
@splattne : Thank you so much :) – LinuxPenseur Feb 17 '11 at 5:35

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:, eth1:, eth2:, eth4: 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: phony 

then phony will resolve to for local services if you have something like this in /etc/hosts: phony

phony will resolve to

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

share|improve this answer

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 and Ch03:_Linux_Networking">


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.