Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Linux
Windows
En este documento, se muestra cómo usar el servidor de metadatos o una herramienta del sistema operativo para detectar si una VM se ejecuta en Compute Engine.
Usa el servidor de metadatos para detectar si una VM se ejecuta en Compute Engine.
Según el sistema operativo de la VM, usa uno de los siguientes procedimientos para enviar una solicitud al servidor de metadatos y detectar si una VM se ejecuta en Compute Engine:
VM de Linux
Desde la VM de Linux, ejecuta el siguiente comando:
curl metadata.google.internal -i
Verifica que Metadata-Flavor: Google exista en un resultado similar al siguiente:
HTTP/1.1 200 OK
Metadata-Flavor: Google
Content-Type: application/text
Date: Tue, 23 Nov 2021 01:27:16 GMT
Server: Metadata Server for VM
Content-Length: 22
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
0.1/
computeMetadata/
La existencia de Metadata-Flavor: Google en el resultado indica que una VM de Compute Engine envió la solicitud.
VM de Windows
Desde la VM de Windows, ejecuta el siguiente comando:
curl metadata.google.internal -i
Verifica que Metadata-Flavor: Google exista en un resultado similar al siguiente:
HTTP/1.1 200 OK
Metadata-Flavor: Google
Content-Type: application/text
Date: Tue, 23 Nov 2021 20:48:50 GMT
Server: Metadata Server for VM
Content-Length: 22
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
0.1/
computeMetadata/
La existencia de Metadata-Flavor: Google en el resultado indica que una VM de Compute Engine envió la solicitud.
Usa las herramientas del sistema operativo para detectar si una VM se ejecuta en Compute Engine
Según el sistema operativo de la VM, usa uno de los siguientes procedimientos para usar una herramienta específica del sistema operativo de la VM a fin de detectar si la VM se ejecuta en Compute Engine:
VM de Linux
Desde la VM de Linux, ejecuta el siguiente comando dmidecode:
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-05-15 (UTC)"],[[["\u003cp\u003eThis guide provides methods to determine if a virtual machine (VM) is running within Google Compute Engine.\u003c/p\u003e\n"],["\u003cp\u003eYou can use the metadata server by sending a request via the \u003ccode\u003ecurl\u003c/code\u003e command on both Linux and Windows VMs and checking for the \u003ccode\u003eMetadata-Flavor: Google\u003c/code\u003e header in the output.\u003c/p\u003e\n"],["\u003cp\u003eLinux VMs can utilize the \u003ccode\u003edmidecode\u003c/code\u003e command to confirm the presence of "Google Compute Engine" in the system product name.\u003c/p\u003e\n"],["\u003cp\u003eWindows VMs can use the \u003ccode\u003ewmic.exe\u003c/code\u003e command to verify that the System Manufacturer is "Google" and the System Model is "Google Compute Engine".\u003c/p\u003e\n"]]],[],null,["Linux Windows\n\n*** ** * ** ***\n\nThis document shows you how to use the metadata server or an operating system\ntool to detect whether a VM is running in Compute Engine.\n\nUse the metadata server to detect if a VM is running in Compute Engine\n\nDepending on the VM's operating system, use one of the following procedures to\nsend a request to the [metadata server](/compute/docs/metadata/overview) and\ndetect if a VM is running in Compute Engine: \n\nLinux VM\n\n1. From the Linux VM, run the following command:\n\n ```\n curl metadata.google.internal -i\n ```\n2. Verify that `Metadata-Flavor: Google` exists in output similar to the\n following:\n\n HTTP/1.1 200 OK\n Metadata-Flavor: Google\n Content-Type: application/text\n Date: Tue, 23 Nov 2021 01:27:16 GMT\n Server: Metadata Server for VM\n Content-Length: 22\n X-XSS-Protection: 0\n X-Frame-Options: SAMEORIGIN\n\n 0.1/\n computeMetadata/\n\n The existence of `Metadata-Flavor: Google` in the output indicates that a\n Compute Engine VM sent the request.\n\nWindows VM\n\n1. From the Windows VM, run the following command:\n\n ```\n curl metadata.google.internal -i\n ```\n2. Verify that `Metadata-Flavor: Google` exists in output similar to the\n following:\n\n HTTP/1.1 200 OK\n Metadata-Flavor: Google\n Content-Type: application/text\n Date: Tue, 23 Nov 2021 20:48:50 GMT\n Server: Metadata Server for VM\n Content-Length: 22\n X-XSS-Protection: 0\n X-Frame-Options: SAMEORIGIN\n\n 0.1/\n computeMetadata/\n\n The existence of `Metadata-Flavor: Google` in the output indicates that a\n Compute Engine VM sent the request.\n\nUse operating system tools to detect if a VM is running in Compute Engine\n\nDepending on the VM's operating system, use one of the following procedures to\nuse a tool that is specific to the VM's operating system to detect if the VM is\nrunning in Compute Engine: \n\nLinux VM\n\n1. From the Linux VM, run the following\n [`dmidecode`](http://www.nongnu.org/dmidecode/)\n command:\n\n ```\n sudo dmidecode -s system-product-name | grep \"Google Compute Engine\"\n ```\n\n This `dmidecode` command directly accesses the System Management BIOS\n information in `/proc/mem`.\n2. Verify that `Google Compute Engine` exists in the output.\n\nWindows VM\n\n1. From the Windows Command Prompt, run the [WMI command-line utility](https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmic):\n\n ```\n wmic.exe computersystem get model,manufacturer\n ```\n2. Verify that the `System Manufacturer` is `Google` and the `System Model` is\n `Google Compute Engine`.\n\nFor information about how to programmatically determine whether a Windows VM\nis running Compute Engine, see the following:\n\n- [Create a WMI application using C++](http://msdn.microsoft.com/library/windows/desktop/aa389762%28v=vs.85%29.aspx)\n- [Getting manufacturer and model from the Windows registry in C++](http://stackoverflow.com/questions/12300442/how-to-get-computer-manufacturer-and-model-from-windows-registry-in-c)"]]