Manage IP addresses
Each instance can have a private, or fixed, IP address and a
public, or floating, one.
Private IP addresses are used for communication between
instances, and public ones are used for communication with the
outside world.
When you launch an instance, it is automatically assigned a
private IP address that stays the same until you explicitly
terminate the instance. Rebooting an instance has no effect on
the private IP address.
A pool of floating IPs, configured by the cloud operator, is
available in OpenStack Compute.
You can allocate a certain number of these to a project: The
maximum number of floating IP addresses per project is defined
by the quota.
You can add a floating IP address from this set to an
instance of the project. Floating IP addresses can be
dynamically disassociated and associated with other instances
of the same project at any time.
Before you can assign a floating IP address to an instance,
you first must allocate floating IPs to a project. After
floating IP addresses have been allocated to the current
project, you can assign them to running instances.
One floating IP address can be assigned to only one instance
at a time. Floating IP addresses can be managed with the
nova *floating-ip-* commands, provided
by the python-novaclient package.
To list pools with floating IP addresses
To list all pools that provide floating IP
addresses:
$ nova floating-ip-pool-list
To allocate a floating IP address to the current
project
The output of the following command shows the
freshly allocated IP address:
$ nova floating-ip-pool-list
If more than one pool of IP addresses is available,
you can also specify the pool from which to allocate
the IP address:
$ floating-ip-create POOL_NAME
To list floating IP addresses allocated to the current
project
If an IP is already associated with an instance, the
output also shows the IP for the instance, thefixed IP
address for the instance, and the name of the pool
that provides the floating IP address.
$ nova floating-ip-list
To release a floating IP address from the current
project
The IP address is returned to the pool of IP
addresses that are available for all projects. If an
IP address is currently assigned to a running
instance, it is automatically disassociated from the
instance.
$ nova floating-ip-delete FLOATING_IP
To assign a floating IP address to an instance
To associate an IP address with an instance, one or
multiple floating IP addresses must be allocated to
the current project. Check this
with:$ nova floating-ip-listIn
addition, you must know the instance's name (or ID).
To look up the instances that belong to the current
project, use the nova list
command.
$ nova add-floating-ip INSTANCE_NAME_OR_ID FLOATING_IP
After you assign the IP with nova
add-floating-ip and configure security group rules for the instance, the instance is
publicly available at the floating IP
address.
To remove a floating IP address from an
instance
To remove a floating IP address from an instance,
you must specify the same arguments that you used to
assign the IP.
$ nova remove-floating-ip INSTANCE_NAME_OR_ID FLOATING_IP