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

  • Posted 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, but here that is not available, nor is there any information in the environment.



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

An old thread, but you can use facter:-

facter manufacturer
# Returns DigitalOcean

You can WHOIS the IP address. If the block belongs to DigitalOcean, it’s most likely a DigitalOcean droplet.

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

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.