[Spread-users] usage of gethostname
Göran Hasse
gorhas at gmail.com
Sat Feb 4 01:07:20 EST 2012
I gathered that there is a new release in pipeline and want to discuss a
small
issue.
In configuration.c there is a usage of gethostname
/* Match my IP address to entry in configuration file */
if( my_name == NULL ){
gethostname(machine_name,sizeof(machine_name));
host_ptr = gethostbyname(machine_name);
But I will argue that the hostname has nothing to do with *interface names*
Line of reasoning... (There is so many names around in a Unix system!).
First we have the KERNELNAME!
This is the current compiled kernel running in the system.
We get this with uname -a and typicaly gives us key information on the
kernel.
Linux fs487 2.6.38-13-generic #53-Ubuntu SMP Mon Nov 28 19:33:45 UTC 2011
x86_64 x86_64 x86_64 GNU/Linux
Then whe have INTERFACE NAMES!
A unix system could have a lot of interfaces
eth0
eth1
eth2
We give them IP-numbers
ifconfig eth0 inet 123.123.123.123 ...
ifconfig eth0:1 inet 234.234.234.234 ...
ifconfig eth1 inet 123.123.123.123 ....
And so on! To handle this long list of interface id we make a database
(DNS) or for convinience
make a small database in /etc/hosts. In this database we holds small
aliases for the interfaces.
/etc/hosts
123.123.123.123 road.to.perdition.org perdition
234.234.234.234 road.to.paradise.org paradise
Then we have the HOSTNAME
This is the name of the *hardware* on which we are running. This name
should NOT! be used in any way in association with the interface names. I
know that this is often so - but it should
not.
So I argue that the function *getaddrinfo* should be used instad. Not that
the manpage
of this function also mix the terminology "node" and "host" in a confusing
manner.
Cordially yours,
Göran Hasse
--
gorhas at gmail.com
Göran Hasse
Boo 229
715 91 ODENSBACKEN
Mob: 070-5530148
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.spread.org/pipermail/spread-users/attachments/20120204/f90b9d5b/attachment.html
More information about the Spread-users
mailing list