Over a million developers have joined DZone.

A crude way of telling if a remote machine is a VM

· Java Zone

Easily build powerful user management, authentication, and authorization into your web and mobile applications. Download this Forrester report on the new landscape of Customer Identity and Access Management, brought to you in partnership with Stormpath.

We were doing a bit of profiling of a data importing process we’ve been running across various environments and wanted to check whether or not one of the environments was a physical machine or a VM.

A bit of googling first led me to the following site where you can fill a MAC address and it will tell you which vendor it belongs to.

macvendorlookup.com is even better though because it’s more easily scriptable!

If I wanted to find the vendor of my MAC address on the ethernet port I could try the following:

ifconfig | grep -A1 en1 | grep ether | cut -d" " -f2 | xargs -I {} 
curl -s http://www.macvendorlookup.com/getoui.php?mac={} -o - | sed -e :a -e 's/<[^>]*>//g;/</N;//ba'

Which gives:

Vendor: Apple Inc

Sed magic was shamelessly stolen from sed one liners.

As it turns out the machine we wanted to learn about was a VM hosted on VMWare!

From http://www.markhneedham.com/blog/2011/07/27/a-crude-way-of-telling-if-a-remote-machine-is-a-vm/

The Java Zone is brought to you by Stormpath—offering a complete, pre-built User Management API for building web and mobile applications, and APIs. Download our new whitepaper: "Build Versus Buy: Customer Identity Management for Web and Mobile Applications".

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}