Unix virtual host detection

Is it possible to reliably detect the virtual host of a Sun Solaris box, within a shell or Perl script?

Can a system have multiple virtual host or not host at all ?

I was recently made aware of hostname command, but was not sure if this option was the only one available.

Any help is much appreciated.

Meridian. :slight_smile:

When you say "virtual host" are you talking about attaching additional IP(s) to an interface?

# cat /etc/hostname.hme0
hosta
# cat /etc/hostname.hem0:1
hostb

etc...

Or something else? If so, you can just look for files of the form /etc/hostname.<interface> that have corresponding entries in /usr/sbin/ifconfig -a

Cheers,

Keith

SMI hardware has a builtin unique hardware id which can
be accessed using hostid(1). I believe that the id is stored
in the NVRAM chip located on the system board.

So, if your script is for Solaris systems only and you wish to
uniquely identify the system this might be the way to go.

  • Finnbarr

A host can use several names on one or mare interfaces as pointed out earlier.

The system official hostname should be the one on the primary interface and is in the file /etc/nodename

HTH