[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: localhost.localdomain

On Fri, Oct 07, 2005 at 11:18:57AM -0700, Russ Allbery wrote:

>  * Obtain the system host name with gethostname().
>  * Look up an IP address for that host with gethostbyname().

The bug is here. This is completely wrong but sadly very common
practice. It is common because it is portable and works with some simple
configurations (namely, single-homed machines with static IP address).

>  * Look up the names associated with that address with gethostbyaddr().
>  * Walk the alias list of the result and find the first name containing
>    a period.

The proper fix would be to enumerate all IP addresses of all network
interfaces and select one that has an appropriate name. Unfortunately
this is non-trivial and highly OS-dependent, although the libdumbnet1
package provides a platform-independent API for this (among other


     MTA SZTAKI Computer and Automation Research Institute
                Hungarian Academy of Sciences

Reply to: