Report this

What is the reason for this report?

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

Posted on March 31, 2014

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,



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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. <br> <br>The only question I would have to someone at DO would be if they limit their DHCP server somehow.

@BossRyan: Forgot to say thanks :-).

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. <br> <br>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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.