A crude way of telling if a remote machine is a VM
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!
About the author
I'm currently working on short form content at ClickHouse. I publish short 5 minute videos showing how to solve data problems on YouTube @LearnDataWithMark. I previously worked on graph analytics at Neo4j, where I also co-authored the O'Reilly Graph Algorithms Book with Amy Hodler.