Attach Fixed IP address to VM

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

  1. Openstack CLI Click here
  2. 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
copy

Replace my-fip-vmcopy 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'                        |
+-----------------------------+------------------------------------------------------------------+
copy

Step 2: Show the the network ID by the following command:

openstack network list
copy

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 |
+--------------------------------------+----------------+--------------------------------------+
copy

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>
copy

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
copy

You can attach any IP address as a FIP, in this article we pick this IP 192.168.0.23copy from and within the CIDR range.

Finally, lets show the instance details and its FIP by the:

openstack server show my-fip-vm
copy

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'                        |
+-----------------------------+------------------------------------------------------------------+
copy

We recommend to shut off your VM before run this command.

From OpenStack graphical user interface

Navigate to Projectcopy > Computecopy > Instancescopy

From the VM’s right side dropdown menu chose Attached interfacecopy

attach interface dashboard

The following window will popup, chose your network and type your fixed ip

attach fip

And then click Attach Interface

Now OpenStack will attach the FIP to the Instance

attach fip result