Oracle Cloud Infrastructure Documentation

Public IP Addresses

This topic describes how to manage public IP addresses on instances in a virtual cloud network (VCN).

Warning

Oracle recommends that you avoid using string values that include confidential information in the Oracle Cloud Infrastructure Console, API, or CLI.

Overview of Public IP Addresses

A public IP address is an IPv4 address that is reachable from the internet. If a resource in your tenancy needs to be directly reachable from the internet, it must have a public IP address. Depending on the type of resource, there might be other requirements.

Certain types of resources in your tenancy are designed to be directly reachable from the internet and therefore automatically come with a public IP address. For example: a NAT gateway or a public load balancer. Other types of resources are directly reachable only if you configure them to be. For example: instances in your VCN.

This topic focuses on these subjects:

  • The types of public IP addresses and their characteristics
  • How to control whether an instance has a public IP address

For more information about resources that automatically get a public IP address, see Resources That Always Get a Public IP.

Instances and Public IP Addresses

You can assign a public IP address to an instance to enable communication with the internet. The instance is assigned a public IP address from the Oracle Cloud Infrastructure address pool.

The assignment is actually to a private IP object on the instance. The VNIC that the private IP is assigned to must be in a public subnet. A given instance can have multiple secondary VNICs, and a given VNIC can have multiple secondary private IPs. So you can assign a given instance multiple public IPs across one or more VNICs if you like.

For an instance to communicate directly with the internet, all of the following are required:

Tip

Oracle Cloud Infrastructure FastConnect public peering lets your on-premises network access the public IP addresses of resources in Oracle Cloud Infrastructure without the traffic traversing the internet. For more information, see FastConnect Overview.

The Public IP Object

The Networking service defines an object called a public IP, which consists of these items:

  • Public IPv4 address (chosen by Oracle)
  • Properties that further define the public IP's type and behavior

Each public IP object has an Oracle-assigned OCID (see Resource Identifiers). If you're using the API, you can also assign each public IP object a friendly name.

Types of Public IPs

There are two types of public IPs:

  • Ephemeral: Think of it as temporary and existing for the lifetime of the instance.
  • Reserved: Think of it as persistent and existing beyond the lifetime of the instance it's assigned to. You can unassign it and then reassign it to another instance whenever you like. Exception: reserved public IPs on public load balancers. See Resources That Always Get a Public IP.

The following table summarizes the differences between the two types.

Characteristic Ephemeral Public IPs Reserved Public IPs
Allowed assignment

To a VNIC's primary private IP only

Limits:

  • One per VNIC
  • Two per VM instance, and 16 per bare metal instance

To either a primary or secondary private IP

Limit: 32 per VNIC

Creation

Optionally created and assigned during instance launch or secondary VNIC creation. You can create and assign one later if the VNIC doesn't already have one.

 

You create one at any time. You can then assign it when you like.

Limit: You can create 50 per region

Unassignment

You can unassign it at any time, which deletes it. You might do this if whoever launched the instance included a public IP, but you don't want the instance to have one.

When you stop an instance, its ephemeral public IPs remain assigned to the instance.

You can unassign it at any time, which returns it to your tenancy's pool of reserved public IPs.
Moving to a different resource

If assigned to a secondary private IP: If you move the private IP to a different VNIC (must be in the same subnet), the ephemeral public IP goes with it.

You cannot move an ephemeral public IP to a different private IP.

If assigned to a secondary private IP: If you move the private IP to a different VNIC (must be in the same subnet), the reserved public IP goes with it.

You can move it (unassign and then reassign it) at any time to another private IP in the same region. Can be in a different VCN or availability domain.

Automatic deletion

Its lifetime is tied to the private IP's lifetime. Automatically unassigned and deleted when:

  • Its private IP is deleted
  • Its VNIC is detached or terminated
  • Its instance is terminated

Never. Exists until you delete it.

Scope Availability domain Regional (can be assigned to a private IP in any availability domain in the region)
Compartment and availability domain Same as the private IP's Can be different from the private IP's

When you launch an instance in a public subnet, by default, the instance gets a public IP unless you say otherwise. See To choose whether an ephemeral public IP is assigned when launching an instance.

After you create a given public IP, you can't change which type it is. For example, if you launch an instance that is assigned an ephemeral public IP with address 129.146.1.9, you can't convert the ephemeral public IP to a reserved public IP with address 129.146.1.9.

The preceding table notes the public IP limits per VNIC and instance. If you try to perform any operation that assigns or moves a public IP to a VNIC or instance that has already reached its public IP limit, an error is returned. The operations include:

  • Assigning a public IP
  • Creating a new secondary VNIC with a public IP
  • Moving a private IP with a public IP to another VNIC
  • Moving a public IP to another private IP

Resources That Always Get a Public IP

As mentioned earlier, certain types of resources are designed to be directly reachable from the internet. Examples: a NAT gateway or a public load balancer. These resources automatically get a public IP address upon creation. Oracle chooses the public IP address from the Oracle pool. You can't remove or change the address.

For public load balancers, the address is a regional reserved public IP that is assigned to a private IP on the load balancer. This public IP appears in the list of your tenancy's reserved public IPs, which you can view in the Console. However, unlike other reserved public IPs that you create, you have no control over this public IP. You can't edit it or unassign it from the load balancer yourself. It's automatically unassigned and deleted from your tenancy when you terminate the load balancer.

For NAT gateways, the address is a regional ephemeral public IP that is assigned to the NAT gateway. Like other ephemeral public IPs, it's automatically unassigned and deleted when you terminate its assigned resource (the NAT gateway). However, unlike other ephemeral public IPs, you can't edit it or unassign it yourself.

Required IAM Policy

To use Oracle Cloud Infrastructure, you must be given the required type of access in a An IAM document that specifies who has what type of access to your resources. It is used in different ways: to mean an individual statement written in the policy language; to mean a collection of statements in a single, named "policy" document (which has an Oracle Cloud ID (OCID) assigned to it); and to mean the overall body of policies your organization uses to control access to resources. written by an administrator, whether you're using the Console or the REST API with an SDK, CLI, or other tool. If you try to perform an action and get a message that you don’t have permission or are unauthorized, confirm with your administrator the type of access you've been granted and which A collection of related resources that can be accessed only by certain groups that have been given permission by an administrator in your organization. you should work in.

For administrators: see IAM Policies for Networking.

Tagging Resources

You can apply tags to your resources to help you organize them according to your business needs. You can apply tags at the time you create a resource, or you can update the resource later with the desired tags. For general information about applying tags, see Resource Tags.

You can apply tags to reserved public IPs, but not ephemeral public IPs.

Ephemeral Public IPs: Using the Console

To choose whether an ephemeral public IP is assigned when launching an instance
To assign an ephemeral public IP when creating a secondary VNIC
To assign an ephemeral public IP to an existing primary private IP
To delete an ephemeral public IP from an instance
To change the display name for an ephemeral public IP

Reserved Public IPs: Using the Console

To view your reserved public IPs
To create a new reserved public IP in your pool
To delete a reserved public IP from your pool
To assign a reserved public IP to a private IP
To unassign a reserved public IP and return it to the pool
To move a reserved public IP from one private IP to another
To change the display name for a reserved public IP
To manage tags for a reserved public IP

Using the API

For information about using the API and signing requests, see REST APIs and Security Credentials. For information about SDKs, see Software Development Kits and Command Line Interface.

To manage public IPs, use these operations:

  • GetPublicIp: Use this to get a publicIp object by specifying its OCID.
  • GetPublicIpByIpAddress: Use this to get a publicIp object by specifying its public IP address.
  • GetPublicIpByPrivateIpId: Use this to get a publicIp object by specifying the OCID of the private IP it's assigned to.
  • ListPublicIps: Use this to list either your ephemeral or reserved publicIp objects.
  • CreatePublicIp: Use this to create a new reserved public IP in your pool.
  • UpdatePublicIp: Use this to assign, reassign, or unassign a reserved public IP, or to update the display name of an ephemeral or reserved public IP. You can also update a reserved public IP's tags.
  • DeletePublicIp: Use this to delete an ephemeral public IP from its private IP, or delete a reserved public IP from your pool. The operation first unassigns the public IP.