[sf-perl] hostname "unknown"

Garth Winter Webb garth at perijove.com
Sun Mar 13 15:28:36 PST 2005


I'm a little confused...is this email a question or an answer?  And if
its an answer, what was the original problem?

If this is a question, why do you need a unique hostname?  In what
subset of machines does it have to be unique (LAN, WAN, just application
servers, etc).  Why would %ENV be populated with "_$hostid" in the first
place?  Why can't you make sure that all your hosts are setup with
proper hostnames?  It seems like an easier solution to fix the DHCP
server settings to always give out a unique hostname, or give each
machine its own host name manually.

Signed,
Missing Context in SF

On Fri, 2005-03-11 at 18:11, David Alban wrote:
> Greetings,
> 
> I find myself in the position of having written a tool or two to be
> run both on machines getting their IP info using dhcp and machines not
> doing so.  The machines in question happen to be running solaris.  I
> get the following for hostname on the dhcp clients:
> 
>   Sys::Hostname::hostname(): unknown
>   Net::Domain::hostfqdn(): unknown.my.domain
>   Net::Domain::hostname(): unknown
> 
> "unknown" is unacceptable because if more than one machine "uses" it,
> we don't have unique hostfqdn's.  One solution is to use a machine's
> hostid as its hostname.
> 
> Another option, which is what I did, also used hostid.  Say my current
> host, a dhcp client, has hostid "8012abcd".  I check for the existence
> of $ENV{ _0812abcd }.  If defined, I use its value as hostname.  If it
> isn't defined, or if I can't determine the hostid of the current host,
> the hostname remains "unknown".
> 
> Heh heh.  As soon as I write this, I realize that what I *should* have
> done is:  if I can get a hostid but the appropriate $ENV{ _nnnnnnnn }
> variable isn't set, I should have used the hostid as the hostname. 
> And if I couldn't get a hostid, I should have (it would be O.K. for my
> application) had the the tool die.  Hmmm... Maybe I'll fix it.
> 
> The reason I look for a $ENV{ _nnnnnnnn } environment variable is that
> some of the hosts running dhcp clients have informal hostnames.  For
> instance, we might think of a host as "foobarbat" even though it's
> hostname() returns "unknown".  If $_nnnnnnnn is set to "foobarbat" in
> the environment, then my tool can report foobarbat as the host's
> hostname.
> 
> I don't mean to present my solution as good, bad, or ugly, but for the
> sake of discussion, I thought it might be interesting to see if others
> had been in the situation where they didn't want to use "unknown" as a
> hostname for dhcp clients, and to see what they did.
> 
> Thanks,
> David
-- 
Garth Winter Webb <garth at perijove.com>


More information about the SanFrancisco-pm mailing list