Change Instance Security Group in OpenStack

In OpenStack, security group is a virtual firewall for the cloud instance. It defines a set of rules and policies that control the network traffic flowing into the instance(inbound) and out of the instance(outbound).

When creating a new instance on OpenStack, you are required to specify security group. If you want to change the current security group or add a new security group to a running instance in OpenStack, use the following steps.

1 – List current Security Groups

List all security groups defined in your OpenStack cloud using openstack CLI.

$ openstack security group list
+--------------------------------------+------------------------------------------------+------------------------+----------------------------------+------+
| ID                                   | Name                                           | Description            | Project                          | Tags |
+--------------------------------------+------------------------------------------------+------------------------+----------------------------------+------+
| 0129c884-586a-4e5e-9a8c-b0bb858dd6a7 | 1fecd7b3-1fe4-4e6c-adaa-41992e2ef5a71719075614 |                        | 3dfc8a0aec3d409696daa2c825b85a3f | []   |
| 03285329-0adb-4151-ac38-e46a6294a397 | default                                        | Default security group | 4dce4b969e3346acb17647cede6bb51d | []   |
| 0421b18a-0ef1-4f4c-b68e-576f78eee200 | 220343e5-b9f6-4874-931f-a00fd3f9626e1718553308 |                        | 3dfc8a0aec3d409696daa2c825b85a3f | []   |
| 2faba89e-4419-40c7-99a3-e43cc71d65b8 | 0cce63a0-f791-4e6b-9772-26784a012fff1718697310 |                        | 3dfc8a0aec3d409696daa2c825b85a3f | []   |
| 7abe316b-ad8b-4dc0-9b18-d4bbe6781a96 | allow_all                                      | Allow all ports        | 3dfc8a0aec3d409696daa2c825b85a3f | []   |
| fd5a602b-a508-409c-bbd9-70711aa6b50f | default                                        | Default security group | 3dfc8a0aec3d409696daa2c825b85a3f | []   |
+--------------------------------------+------------------------------------------------+------------------------+----------------------------------+------+

2 – Adding a Security Group to an Instance

Check commands for adding security group to an instance – help page.

$ openstack server add security group --help
usage: openstack server add security group [-h] <server> <group>

Add security group to server

positional arguments:
  <server>  Server (name or ID)
  <group>   Security group to add (name or ID)

optional arguments:
  -h, --help        show this help message and exit

The command syntax is:

openstack server add security group <instance_id_or_name> <security_group_name_or_id>

In our example we’re adding security group allow_all to an instance web-server1.

openstack server add security group web-server1 allow_all

Query current default security group for an instance.

$ openstack server show web-server1|grep security_groups
| security_groups                     | name='allow_all'

That’s all. Your OpenStack instance is now using assigned rules defined in the security group attached. Don’t hesitate to contact us for support on OpenStack related platforms and projects.

Your IT Journey Starts Here!

Ready to level up your IT skills? Our new eLearning platform is coming soon to help you master the latest technologies.

Be the first to know when we launch! Join our waitlist now.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

GlassFish is an open-source application server project started by Sun Microsystems for the Java EE platform, then sponsored by Oracle […]

This article will cover how to install Wine 8.x on Rocky Linux 8 / AlmaLinux 8. Wine is an application […]

Java is a high-level object-oriented programming language and computing platform intended to let application developers write once and run everywhere. […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.