Question

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

Posted March 31, 2014 2k views
As the title says, for provisioning purposes I need to find out whether the VM is running in digitalocean. In aws, I query 169.254.169.254, but here that is not available, nor is there any information in the environment. Thanks,

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
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.
Submit an Answer