How to Assign a Fixed IP to an Instance
A private or fixed IP is assigned to an instance based off the network specified on boot. However, the need may arise to re-assign this fixed IP in certain situations.
For example, consider a scenario where a fixed IP associated with an instance is hardcoded into or otherwise being referenced by your application, and the instance needs to be taken down for maintenance while maintaining minimal downtime for the application. Hence, another instance needs to be created to take its place with the same IP.
When such a scenario arises, it is required to re-assign the fixed IP of the instance which is undergoing maintenance to the replacement instance.
Environment
Platform9 Managed OpenStack
OpenStack CLI
Nova
Neutron
Procedure
For each step, run the provided command on the host for which you have the OpenStack CLI installed.
Remove the IP from the instance.
openstack server remove fixed ip <INSTANCE_ID> <IP>Add a new IP to the instance.
openstack server add fixed ip --fixed-ip-address <IP> <INSTANCE_ID> <NETWORK_ID>Troubleshooting
The following describes any known issues which may arise while performing this procedure and tips on how to resolve them.
Flag --fixed-ip-address is not recognized
An older version of the OpenStack CLI is installed. An upgrade of the CLI package is necessary for this flag to be recognized. Refer to the OpenStack CLI section below for guidance on installing the latest CLI client.
Additional Information
LBaaS
Leveraging LBaaS (Load Balancer as a Service) is also an option which would allow you to maintain a static IP/endpoint for multiple instances.
External Networks
A floating IP could be used for this purpose if utilizing an external network.
For more information on external networks, refer to Networking Concepts
OpenStack CLI
For guidance with installing the CLI client on your machine, refer to Installing OpenStack CLI Clients.
Last updated
Was this helpful?
