Search code examples
google-compute-engine

My Compute Engine VM has no external IP. What do other servers see?


My Google Cloud Compute Engine VM Instance claims to have no external IP address in the settings.

When I run the following code, I get an IP address.

response = requests.get('http://jsonip.com')
ip = response.json()['ip']
print('Your public IP is:', ip)

>>> Your public IP is: x.x.x.x  <-- Masking the IP address for security reasons

What address is returned? Is this just a non-static IP address?


Solution

  • The host is seeing the IP address for the Google Cloud NAT Gateway configured for the VPC. If a VPN is configured and is the default route, the host will see the router's IP address.

    Google Cloud NAT Gateways use a static public IP address.

    VPNs use whatever is configured and could be a single public static IP address or a group of IP addresses.