views:

2549

answers:

5

I have a VMWARE ESX server. I have Redhat VMs running on that server. I need a way of programatically testing if I'm running in a VM. Ideally, I'd like to know how to do this from Perl.

+6  A: 

See the answer to Detect virtualized OS from an application?.

Jonas Gulle
+2  A: 

VMWare has a couple of SDK's, including an SDK for Perl.

Graeme Perrow
+1  A: 

I think (depending on the version of esx) you can inspect at the MAC address of the NIC. VMs running in VMWare NIC will have a manufacturer string assigned to VMWare, no the physical NIC MAC. (We were trying to spoof the MAC to VM a license server and newer versions won't let you do it.) Also, this won't guarantee you aren't running on a physical box with a NIC spoofed to look like VMWare, but that would be an odd thing to do in most circumstances anyway.

gsarnold
Virtualbox lets you enter any MAC you want
Martin Beckett
@mgb fair enough, but OP was asking about VMware ESX..
sascha
I would assume that you can change it in ESX. It's a very useful feature if you are trying to run licenced apps in a VM
Martin Beckett
+4  A: 

You shouldn't 100% depend on any method, as they are undocumented features/bugs - they work on some host OSes and some virtualization solutions, but there is no guarantee that they will continue working; indeed, the whole point of virtualization is to be as undistinguishable from real metal as possible. With this in mind, the blue pill red pill (which is mentioned in the accepted answer to this similar question) seems to work ... for now.

Piskvor
+1  A: 

Try the Red Pill.

andyh_ky