Some workload application requires Fixed IP address such as: Fireall, LB , DNS, AD ..etc
To attach Fixed ip to your VM, follow the following Steps:
Prerequisites
- Openstack CLI Click here
- Create network and VM Click here
From OpenStack command line interface
Step 1: Show the instance ID by the following command:
openstack server show my-fip-vm
Replace my-fip-vm
with your VM name.
The output will look something like this:
+-----------------------------+------------------------------------------------------------------+
| Field | Value |
+-----------------------------+------------------------------------------------------------------+
| OS-DCF:diskConfig | AUTO |
| OS-EXT-AZ:availability_zone | zone-1 |
| OS-EXT-STS:power_state | Running |
| OS-EXT-STS:task_state | None |
| OS-EXT-STS:vm_state | active |
| OS-SRV-USG:launched_at | 2022-10-30T10:24:07.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | My_FIP_network=192.168.0.17 |
| config_drive | |
| created | 2022-10-30T10:23:50Z |
| flavor | R1-Generic-1 (28ea78e0-e576-4853-a735-09e89973d9a8) |
| hostId | 187b1c2d7af8224ff97dc583775befcd2977398db0fc448f7a489583 |
| id | c5050b1b-2c01-44eb-890a-4ab8cbc76752 |
| image | N/A (booted from volume) |
| key_name | fipkey |
| name | my-fip-vm |
| progress | 0 |
| project_id | 6ad04a695b1c6767787870227aa2 |
| properties | |
| security_groups | name='default' |
| | name='default' |
| | name='fipsecurity' |
| status | ACTIVE |
| updated | 2022-10-30T10:24:07Z |
| user_id | 6fb395d49e91878d7f8df78s87sd7805bb0e855b43b6a928bfeff6ba1f06d73a |
| volumes_attached | id='cd5eb517-14f9-468b-9d2d-ae525a86533a' |
+-----------------------------+------------------------------------------------------------------+
Step 2: Show the the network ID by the following command:
openstack network list
The output will look something like this:
+--------------------------------------+----------------+--------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+----------------+--------------------------------------+
| cc79838d-19eb-4230-a642-eaec3f4be55d | My_FIP_network | a722e698-b082-4eb5-baa3-2bcb4e21bb95 |
| c975f064-d2b8-413c-9493-981f68bf887a | Public_Network | f661f581-3ec6-44ad-92cb-704ef76ab45d |
+--------------------------------------+----------------+--------------------------------------+
Step 3: Attach Fixed IP to the running instance by the following command:
openstack server add fixed ip --fixed-ip-address <FIXED-IP> <INSTANCE-ID> <NETWORK-ID>
So our command will be like the following:
openstack server add fixed ip --fixed-ip-address 192.168.0.23 c5050b1b-2c01-44eb-890a-4ab8cbc76752 cc79838d-19eb-4230-a642-eaec3f4be55d
You can attach any IP address as a FIP, in this article we pick this IP 192.168.0.23
from and within the CIDR range.
Finally, lets show the instance details and its FIP by the:
openstack server show my-fip-vm
The output will look something like this:
+-----------------------------+------------------------------------------------------------------+
| Field | Value |
+-----------------------------+------------------------------------------------------------------+
| OS-DCF:diskConfig | AUTO |
| OS-EXT-AZ:availability_zone | zone-1 |
| OS-EXT-STS:power_state | Running |
| OS-EXT-STS:task_state | None |
| OS-EXT-STS:vm_state | active |
| OS-SRV-USG:launched_at | 2022-10-30T10:24:07.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | My_FIP_network=192.168.0.17, 192.168.0.23 |
| config_drive | |
| created | 2022-10-30T10:23:50Z |
| flavor | R1-Generic-1 (28ea78e0-e576-4853-a735-09e89973d9a8) |
| hostId | 187b1c2d7af8224ff97dc583775befcd2977398db0fc448f7a489583 |
| id | c5050b1b-2c01-44eb-890a-4ab8cbc76752 |
| image | N/A (booted from volume) |
| key_name | fipkey |
| name | my-fip-vm |
| progress | 0 |
| project_id | 6ad04a695b1c6767787870227aa2 |
| properties | |
| security_groups | name='default' |
| | name='default' |
| | name='fipsecurity' |
| status | ACTIVE |
| updated | 2022-10-30T10:24:07Z |
| user_id | 6fb395d49e91878d7f8df78s87sd7805bb0e855b43b6a928bfeff6ba1f06d73a |
| volumes_attached | id='cd5eb517-14f9-468b-9d2d-ae525a86533a' |
+-----------------------------+------------------------------------------------------------------+
We recommend to shut off your VM before run this command.
From OpenStack graphical user interface
Navigate to Project
> Compute
> Instances
From the VM’s right side dropdown menu chose Attached interface
The following window will popup, chose your network and type your fixed ip
And then click Attach Interface
Now OpenStack will attach the FIP to the Instance