Many Google Cloud resources can have internal IP addresses and external IP addresses. Instances use these addresses to communicate with other Google Cloud resources and external systems.
To learn how to create and manage IP addresses for your resources, read Reserving a static external IP address.
To learn about secondary internal IP addresses, read the Alias IP ranges overview.
In Google Cloud, you can assign an IP address to certain resources. For example, you can assign an internal and external IP address to Compute Engine virtual machine (VM) instances. Similarly, you can assign an internal or external IP address to a forwarding rule for internal or external load balancing, respectively.
Each VM instance network interface must have one primary internal IP address, can have one or more alias IP ranges, and can have one external IP address. To communicate between instances on the same Virtual Private Cloud (VPC) network, you can use the internal IP address for the instance. To communicate with the internet, you must use the instance's external IP address unless you have configured a proxy of some kind. Similarly, you must use the instance's external IP address to connect to instances outside of the same VPC network unless the networks are connected in some way, like by using Cloud VPN. Both external and internal primary IP addresses can be either ephemeral or static.
A forwarding rule is required for network, global, and internal load balancing. The forwarding rule must have an external or internal IP address, depending on the load balancer you are using. For network and global load balancing, you can create a regional or global forwarding rule and allocate a regional or global static external IP address, respectively. For internal load balancing, assign an internal IP address.
For information about identifying the internal and external IP address for your instances, see Locating the external and internal IP address for an instance.
For information about the possible external IP addresses that Google Cloud might assign to a VM, see Where can I find Compute Engine IP ranges?.
Try it for yourself
If you're new to Google Cloud, create an account to evaluate how Compute Engine performs in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.Try Compute Engine free
External IP addresses
You can assign an external IP address to an instance or a forwarding rule if you need to communicate with the internet, with resources in another network, or with a resource outside of Compute Engine. Sources from outside a Google Cloud VPC network can address a specific resource by the external IP address, as long as firewall rules allows the connection. Only resources with an external IP address can send and receive traffic directly to and from outside the network. Communicating with a resource using an external IP address can cause additional billing charges, even if the sender is in the same VPC network. For a list of Compute Engine IP ranges, see Networking.
Compute Engine supports two types of external IP addresses:
Static external IP addresses: these addresses are assigned to a project long term until they are explicitly released from that assignment, and they remain attached to a resource until they are explicitly detached.
For VM instances, static external IP addresses remain attached to stopped instances until they are removed.
Ephemeral external IP addresses: these addresses are available to VM instances and forwarding rules. Ephemeral external IP addresses remain attached to a VM instance only until the VM is stopped and restarted or the instance is terminated. If an instance is stopped, any ephemeral external IP addresses that were assigned to the instance are released back into the general Compute Engine pool and become available for use by other projects. When a stopped instance is started again, a new ephemeral external IP address is assigned to the instance.
To assign multiple external IP addresses to a single instance, you can set up multiple forwarding rules to point to a single target instance using protocol forwarding.
Static external IP addresses
You can reserve a static external IP address, which assigns the address to your project indefinitely until you explicitly release it. This is useful if you depend on a specific IP address for your service and need to prevent others from being able to use the address. You can reserve a new static external IP address or promote an existing ephemeral external IP address to a static external IP address.
Static external IP addresses can be either a regional or a global resource. A regional static IP address lets resources of that region or resources of zones within that region use the IP address. In this case, VM instances and regional forwarding rules can use a regional static IP address.
Global static external IP addresses are available only to global forwarding rules, which are used for global load balancing. You can not assign a global IP address to a regional or zonal resource like a Compute Engine instance.
You can use your own publicly routable IP address prefixes as Google Cloud external IP addresses and advertise them on the internet. For more information, see Bring your own IP (BYOIP). While BYOIP addresses are static external IP addresses, and can be used with most resources that support static external IP addresses, there are some limitations.
Ephemeral external IP addresses
An ephemeral external IP address is an IP address that does not persist beyond the life of the resource. When you create an instance or forwarding rule without specifying an IP address, the resource is automatically assigned an ephemeral external IP address.
Ephemeral external IP addresses are released from a resource if you delete the resource. For VM instances, the ephemeral external IP address is also released if you stop the instance. After you restart the instance, it is assigned a new ephemeral external IP address. If you have an existing VM that does not have an external IP address, you can assign one to it. Forwarding rules always have an IP address, whether external or internal, so you don't need to assign an IP address to a forwarding rule after it is created.
Primary internal IP addresses
Every VM instance can have one primary internal IP address that is unique to the VPC network. You can assign a specific internal IP address when you create a VM instance, or you can reserve a static internal IP address for your project and assign that address to your resources. If you don't specify an address, Compute Engine assigns one automatically. In either case, the address must belong to the IP range of the subnet.
- If your network is an auto mode VPC network, the address comes from the region's subnet.
- If your network is a custom mode VPC network, you must specify which subnet the IP address comes from.
- If your network is a legacy network, the IP address is assigned from the network's global internal IP range.
You can address packets to a VM instance by using the internal IP address of the instance. The internal IP address is only accessible from other instances in the same network or in a network that is linked, such as through Cloud VPN. These instances can be located in any region in the same network or linked network.
Compute Engine supports two types of internal IP addresses:
Static internal IP addresses: these addresses are assigned to a project long term until they are explicitly released from that assignment, and remain attached to a resource until they are explicitly detached from the resource.
For VM instances, static internal IP addresses remain attached to stopped instances until they are removed.
Ephemeral internal IP addresses: these addresses are available to VM instances and forwarding rules. Ephemeral internal IP addresses remain attached to VM instances and forwarding rules until the instance or forwarding rule is deleted.
You can assign an ephemeral internal IP address when you create a resource by omitting an IP address specification in your request and letting Compute Engine randomly assign an address.
For internal load balancers, you can assign a static internal IP address, specify an explicit ephemeral internal IP address, or let Google Cloud assign an ephemeral internal IP address randomly. For more information about specifying an IP address for an internal load balancer, read Internal IP address in the internal load balancing documentation.
Instances can also have alias IP addresses and ranges. If you have more than one service running on a VM, you can assign each service its own unique IP address.
Internal DNS names
If you are communicating between instances in the same VPC network, you can send packets to an instance by specifying the fully qualified DNS name (FQDN) of the target instance. Google Cloud automatically resolves the name to the internal IP address of the instance.
For more information about fully qualified domain names (FQDN), see Internal DNS.
- Locating the external and internal IP address for an instance.
- Reserve a new static external IP address.
- Assigning a static external IP to a new VM instance.
- Choosing an internal IP address at instance creation.
- Promoting an ephemeral external IP address.
- Learn how to use internal DNS names to address instances over the internal VPC network.
- Review external IP address pricing.