Hostname resolution in a machine with multiple running eth ports
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
Related videos on Youtube
LinuxPenseur
nitin_cherian: Sneior Lead Engineer at ADVA Optical Networking, Bangalore, India Languages worked on: C, C++, Python Operating systems worked on: Linux Current Interests: Python Language, Game development in Python. Crafting Quality code in Python. Online Courses: Cryptography1, Interactive Programming in Python @ www.coursera.com. Hobbies: Reading short articles in newspaper and magazines.
Updated on September 17, 2022Comments
-
LinuxPenseur over 1 year
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