8.9.3. Adding Floating IP Addresses

This procedure details the definition of a pool of floating IP addresses. It also covers the reservation of a floating IP address from the pool and the association of that address with a specific Compute instance.

Procedure 8.7. Adding Floating IP Addresses using the Command Line Interface

  1. Use the nova-manage floating create command to define a pool of floating IP addresses.
    $ nova-manage floating create IP_BLOCK
    Replace IP_BLOCK with the block of IP addresses to use. This value is expressed using CIDR notation.

    Example 8.5. Defining a Pool of Floating IP Addresses

    $ nova-manage floating create 172.31.0.224/28
  2. Use the nova floating-ip-create command to reserve a floating IP address from the available blocks of public IP addresses.
    $ nova floating-ip-create
    +--------------+-------------+----------+------+
    |      Ip      | Instance Id | Fixed Ip | Pool |
    +--------------+-------------+----------+------+
    | 172.31.0.225 |             |          | nova |
    +--------------+-------------+----------+------+
  3. Use the nova list command to identify running instances and select an instance to assign the floating IP address to.
    $ nova list
    +--------------------------------------+-------------------+--------+------------------+
    |                  ID                  |        Name       | Status |     Networks     |
    +--------------------------------------+-------------------+--------+------------------+
    | 0e4011a4-3128-4674-ab16-dd1b7ecc126e | rhel              | ACTIVE | demonet=10.0.0.1 |
    +--------------------------------------+-------------------+--------+------------------+
  4. Use the nova add-floating-ip command to assign the floating IP address that reserved in an earlier step to the selected instance.
    $ nova add-floating-ip INSTANCE IP
    Replace INSTANCE with the identifier of the selected instance and replace IP with the floating IP address being assigned to it.

    Example 8.6. Assigning a Floating IP Address to an Instance

    $ nova add-floating-ip 0e4011a4-3128-4674-ab16-dd1b7ecc126e 172.31.0.225
  5. Periodically check the output of the nova list command until the floating IP address appears in the output for the selected instance. Once this occurs the instance is accessible using the floating IP address.

    Note

    To disassociate a floating IP address from an instance when it is no longer required, use the nova remove-floating-ip command.
    $ nova remove-floating-ip INSTANCE IP
    Replace INSTANCE with the identifier of the instance and replace IP with the floating IP address to remove from it.
You have successfully associated a floating IP address with an instance using the command line interface.