Assign a Floating IP to Server Instance in OpenStack

Creating and assigning a floating IP to a server instance in OpenStack using the CLI involves several steps: creating the floating IP, associating it with an instance, and verifying the assignment.

Step 1: Source Your OpenStack RC File

sudo -i -u stack
cd ~/devstack
source openrc <USERNAME> <PROJECT_NAME>

Step 2: Create a Floating IP

Create a floating IP on your external network.

openstack network list
openstack floating ip create <EXTERNAL_NETWORK>

Step 3: Associate the Floating IP with the Instance

Associate the floating IP with your server instance.

openstack server add floating ip <INSTANCE_NAME> <FLOATING_IP>

openstack server add floating ip my-server 172.24.4.121

Step 4: Verify the Floating IP Assignment

Verify that the floating IP has been associated with your instance.

openstack server show <INSTANCE_ID>