Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 249
nitin_cherian Avatar asked Mar 09 '26 04:03

nitin_cherian


2 Answers

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

like image 178
Erik Avatar answered Mar 12 '26 01:03

Erik


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

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

like image 43
Lightness Races in Orbit Avatar answered Mar 12 '26 01:03

Lightness Races in Orbit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!