How can I detect whether a VM is running in DigitalOcean, from within the VM

March 31, 2014 1.4k views
As the title says, for provisioning purposes I need to find out whether the VM is running in digitalocean. In aws, I query, but here that is not available, nor is there any information in the environment. Thanks,
4 Answers
My thought would be to take the IP assigned to the VM and do a reverse lookup and see if it is registered to Digital Ocean. If I am understanding correctly you want to know if you are running a vm inside a vm. I would expect unless you have a private IP, you should have something off the DO servers.

The only question I would have to someone at DO would be if they limit their DHCP server somehow.
Hi BossRyan, I had thought of that, but it seemed a bit convoluted. I hoped there would be an easier way, something that possibly they either would inject in the VM or just a way to ask the infrastructure as it happens in openstack based clouds if my memory serves me well.

Also, my idea is not to run a VM within a VM, I was just referring to the actual VM you get when you launch a droplet, as it is running on top of some sort of Virtualization infrastructure, possibly Xen, KVM or something else.
@BossRyan: Forgot to say thanks :-).
You can WHOIS the IP address. If the block belongs to DigitalOcean, it's most likely a DigitalOcean droplet.
Have another answer? Share your knowledge.