Managing floating IP addresses using the OpenStack CLI


This is only relevant if you have private networking enabled. If you are using public networking you will only have public IPv4 and IPv6 addresses.

When an instance is attached to a private network, it has a private, fixed IP address and can also have a public, or floating IP address. Private IP addresses are used for communication between instances, and public addresses are used for communication with networks outside the cloud, including the Internet.

When you launch an instance, it is automatically assigned a private IP address that stays the same until you explicitly delete the instance. Rebooting an instance has no effect on the private IP address.

A pool of floating IP addresses is available in DreamCompute. Your project's quota defines the maximum number of floating IP addresses that you can allocate to your project. After you allocate a floating IP address to your project, you can:

  • Associate the floating IP address with one of your instances (note: only one floating IP address can be allocated to an instance at any given time).
  • Disassociate a floating IP address from one of your instances.
  • Release a floating IP address from your project (this automatically deletes any associations that address has).

Use the openstack floating ip commands to manage floating IP addresses.

List floating IP address information

To list all pools that provide floating IP addresses, run:

[user@localhost]$ openstack floating ip pool list
| Name   |
| public |

To list all floating IP addresses that are allocated to your project, run:

[user@localhost]$ openstack floating ip list
| ID                    | Floating IP Address | Fixed IP Address | Port                  |
| 0c2a8ac8-3946-4a8c... |        |         | 160d92fe-a2a5-4670... |
| 2f0d10fb-c280-4b85... |        |         | 3f344480-587b-4034... |
| fa3e0a06-abcc-4a33... |        | None             | None                  |

For each floating IP address that is allocated to your project, the command outputs the ID of the floating IP address, the actual floating IP address, the private IP address of the instance the floating IP address is associated with, and the ID for the port that the floating IP address is connected to.

Allocating/Associating floating IP addresses

You can assign a floating IP address to a project and to an instance.

  1. Run the following command to allocate a floating IP address to your project. The command outputs the allocated IP address:
    [user@localhost]$ openstack floating ip create public
    | Field       | Value                  |
    | fixed_ip    | None                   |
    | id          | fb25df2b-b2c8-4286...  |
    | instance_id | None                   |
    | ip          |           |
    | pool        | public                 |
  2. List all project instances with which a floating IP address could be associated.
    [user@localhost]$ openstack server list --ip 10.0.0.
    | ID                    | Name | Status | Networks         |
    | 71e499c1-7b9d-42b9... | VM1  | ACTIVE | private= |
    | f94123d8-99f1-411c... | VM2  | ACTIVE | private= |

    In the command above, '10.0.0.' is an example. You need to enter the value that matches the Network Address of the Subnet you used when creating your private network as described here.

  3. Associate an IP address with an instance in the project, as follows:
    [user@localhost]$ openstack floating ip add FLOATING_IP_ADDRESS INSTANCE_ID

    For example:

    [user@localhost]$ openstack floating ip add 71e499c1-7b9d-42b9...

The instance is now associated with two IP addresses:

[user@localhost]$ openstack server list --ip 10.0.0.
| ID                    | Name | Status | Networks                       |
| 71e499c1-7b9d-42b9... | VM1  | ACTIVE | private=, |
| f94123d8-99f1-411c... | VM2  | ACTIVE | private=               |

After you associate the IP address and configure security group rules for the instance, the instance is publicly available at the floating IP address.

Disassociate floating IP addresses

To disassociate a floating IP address from an instance:

[user@localhost]$ openstack floating ip remove FLOATING_IP_ADDRESS INSTANCE_NAME_OR_ID

To remove a floating IP address from your project:

[user@localhost]$ openstack floating ip delete FLOATING_IP_ADDRESS

The IP address is returned to the pool of IP addresses that is available for all projects. If the IP address is still associated with a running instance, it is automatically disassociated from that instance.

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?