nitin_cherian
nitin_cherian

Reputation: 6675

Linux hostname resolution on a machine with multiple running interfaces

I have 4 running eth ports on my Linux machine (eth0 through eth3). So if i give the command host <hostname>, which eth port's ipaddress will be returned? how does linux decide which eth port's ip address to be returned?

Thanks, LinuxPenseur

Upvotes: 3

Views: 9903

Answers (2)

Lightness Races in Orbit
Lightness Races in Orbit

Reputation: 385385

What's your "primary" interface? That one is used.

http://ubuntuforums.org/archive/index.php/t-1120370.html

Upvotes: 2

Erik
Erik

Reputation: 91320

host does not look at your local IPs, it looks up the hostname based on the rules specified in /etc/nsswitch.conf

In nsswitch.conf you will typically have this entry:

hosts: files dns

This means that the resolver will first check /etc/hosts, if it cannot find anything there it'll check /etc/resolv.conf and ask the specified DNS servers for the IP, optionally appending the "search" and "domain" suffixes specified in resolv.conf

See http://www.faqs.org/docs/linux_network/x-087-2-resolv.library.html

Upvotes: 4

Related Questions