Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

Thanks

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

2 Answers

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

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

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.