OpenStack instance Creation









It is quite easy for Web Administrators to create an instance with a fixed static IP address in OpenStack by using network ports. Each instance has a private, fixed IP address.

Therefore, it is necessary to configure a pool of floating IP addresses.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform OpenStack related tasks.
In this context, we shall look into the steps to create an OpenStack instance with a Fixed or Static IP address.

How to create OpenStack instance with a Fixed/Static IP address?

In an OpenStack Cloud environment, the default IP assignment mechanism is through DHCP. We can assign a fixed static IP address in OpenStack by creating ports and adding them to the instance.
A port is a connection point for attaching a single device, such as the NIC of a server, to a network.
The port also describes the associated network configuration, such as the MAC and IP addresses to be used on that port.
Let us now discuss the steps to perform this task.

1. How to Create a network port?

Use the command openstack port create to create a new port on the specified network.
Let us see all available command arguments.

$ openstack port create --help
.....
openstack port create --help
usage: openstack port create [-h] [-f {json,shell,table,value,yaml}]
[-c COLUMN] [--noindent] [--prefix PREFIX]
[--max-width <integer>] [--fit-width]
[--print-empty] --network <network>
[--description <description>]
[--device <device-id>]
[--mac-address <mac-address>]
[--device-owner <device-owner>]
[--vnic-type <vnic-type>] [--host <host-id>]
[--dns-name dns-name]
[--fixed-ip subnet=<subnet>,ip-address=<ip-address> | --no-fixed-ip]
[--binding-profile <binding-profile>]
[--enable | --disable] [--project <project>]
[--project-domain <project-domain>]
[--security-group <security-group> | --no-security-group]
[--qos-policy <qos-policy>]
[--enable-port-security | --disable-port-security]
[--allowed-address ip-address=<ip-address>[,mac-address=<mac-address>]]
[--tag <tag> | --no-tag]
<name>
......


Additionally, you can list available networks and subnets by running the command below:

$ openstack network list

+--------------------------------------+---------+--------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+---------+--------------------------------------+
| b94431cb-08cf-42ea-be61-55f5cf459276 | private | 57601b99-ea64-41a8-a927-fbd591ae3f2b |
| f7ccac3b-73eb-49bf-a4ec-af750216b819 | public | 7536e4a8-6aa8-45dc-aed6-1a98afcf416d |
+--------------------------------------+---------+--------------------------------------+


$ openstack subnet list --network private

+--------------------------------------+----------------+--------------------------------------+--------------+

| ID | Name | Network | Subnet |

+--------------------------------------+----------------+--------------------------------------+--------------+

| 57601b99-ea64-41a8-a927-fbd591ae3f2b | private_subnet | b94431cb-08cf-42ea-be61-55f5cf459276 | 10.10.1.0/24 |

+--------------------------------------+----------------+--------------------------------------+--------------+


In order to create a port with a fixed IP address on the private network, execute;

openstack port create --network private --fixed-ip \
subnet=private_subnet,ip-address=10.10.1.20 server1-port0


To Confirm port creation, run;

$ openstack port list
$ openstack port show server1-port0

How to create a Server with fixed IP in OpenStack?

Now that the port is created, we can boot a new instance with a preserved IP address;

openstack server create \
--image CentOS-7 \
--flavor m1.small \
--security-group 7fffea2a-b756-473a-a13a-219dd0f1913a \
--port server1-port0 \
server1


Now, check server status with the command below:

$ openstack server show server1

We should be able to reach the new server that we created with a fixed IP.

$ ping -c 2 10.10.1.20
PING 10.10.1.20 (10.10.1.20) 56(84) bytes of data.
64 bytes from 10.10.1.20: icmp_seq=1 ttl=64 time=0.768 ms
64 bytes from 10.10.1.20: icmp_seq=2 ttl=64 time=0.491 ms
--- 10.10.1.20 ping statistics ---

[Need urgent assistance to create OpenStack instance? – We are available 24*7]

Conclusion

This tutorial is all about assigning a fixed static IP address in OpenStack by creating ports and adding them to the instance.