Product SiteDocumentation Site

6.5. Adding Floating IP Addresses

Floating IP addresses are typically used for assigning public IP addresses to instances. First you create a pool of addresses using nova-manage. Then you can use the nova command to reserve an address and apply it to an instance.
$ sudo nova-manage floating create 172.31.0.224/28
$ nova floating-ip-create
+--------------+-------------+----------+------+
|      Ip      | Instance Id | Fixed Ip | Pool |
+--------------+-------------+----------+------+
| 172.31.0.225 | None        | None     | nova |
+--------------+-------------+----------+------+
$ nova floating-ip-list
+--------------+-------------+----------+------+
|      Ip      | Instance Id | Fixed Ip | Pool |
+--------------+-------------+----------+------+
| 172.31.0.225 | None        | None     | nova |
+--------------+-------------+----------+------+
$ nova list
+--------------------------------------+-------------------+--------+------------------+
|                  ID                  |        Name       | Status |     Networks     |
+--------------------------------------+-------------------+--------+------------------+
| 0e4011a4-3128-4674-ab16-dd1b7ecc126e | rhel              | ACTIVE | demonet=10.0.0.2 |
| ac9e6a9f-58c3-47c3-9b4c-485aa421b8a8 | snapshot-instance | ACTIVE | demonet=10.0.0.4 |
| b8d5c952-f2fc-4556-83f2-57c79378d867 | rhel2             | ACTIVE | demonet=10.0.0.3 |
+--------------------------------------+-------------------+--------+------------------+
$ nova add-floating-ip 0e4011a4-3128-4674-ab16-dd1b7ecc126e 172.31.0.225
The previous step may take a little bit of time to apply. Watch the output of nova list for the floating IP address to show up in the Networks column of the output. After a short time you should be able to ssh to the instance using its floating IP address.
$ ssh -i oskey.priv root@172.31.0.225
Once you no longer need the floating IP address for an instance, you can remove it. Once the IP address has been removed, it should no longer show up in the output of nova list.
$ nova remove-floating-ip 0e4011a4-3128-4674-ab16-dd1b7ecc126e 172.31.0.225