Is there a way to know from a command line shell if I am currently on a Google Compute Engine machine or somewhere else (development machine)?
Here is python implementation via socket.getaddrinfo
import socket def is_gce_instance(): """Check if it's GCE instance via DNS lookup to metadata server. """ try: socket.getaddrinfo('metadata.google.internal', 80) except socket.gaierror: return False return True