# Unix virtual host detection

**URL:** <https://community.unix.com/t/unix-virtual-host-detection/147850>\
**Category:** Solaris\
**Created:** [January 14, 2004, 7:26pm UTC](https://community.unix.com/t/unix-virtual-host-detection/147850 "2004-01-14T19:26:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meridian](https://community.unix.com/letter_avatar/meridian/32/6_22734026db12803ebb3e059622ac3534.png) [@Meridian](https://community.unix.com/u/Meridian)\
**Post date:** [January 14, 2004, 7:26pm UTC](https://community.unix.com/t/unix-virtual-host-detection/147850/1 "2004-01-14T19:26:34Z")

</div>

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. 🙂

---

<div class="post-metadata">

**Author:** ![kduffin](https://community.unix.com/user_avatar/community.unix.com/kduffin/32/105_2.png) [@kduffin](https://community.unix.com/u/kduffin)\
**Post date:** [January 14, 2004, 9:12pm UTC](https://community.unix.com/t/unix-virtual-host-detection/147850/2 "2004-01-14T21:12:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fpmurphy](https://community.unix.com/user_avatar/community.unix.com/fpmurphy/32/110_2.png) [@fpmurphy](https://community.unix.com/u/fpmurphy)\
**Post date:** [January 18, 2004, 8:31pm UTC](https://community.unix.com/t/unix-virtual-host-detection/147850/3 "2004-01-18T20:31:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bsd](https://community.unix.com/letter_avatar/bsd/32/6_22734026db12803ebb3e059622ac3534.png) [@bsd](https://community.unix.com/u/bsd)\
**Post date:** [January 20, 2004, 3:55am UTC](https://community.unix.com/t/unix-virtual-host-detection/147850/4 "2004-01-20T03:55:23Z")

</div>

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
