Managing firewall rules and port security on networks using OpenStack CLI
Objective
The OpenStack platform manages firewall security by combining connection rules into security groups. Rules are then applied by assigning security groups to networking ports.
A port in the context of OpenStack Neutron is a point of connection between subnets and networking elements (such as instances, load balancers, routers etc.).
This guide explains how security groups for public and private networks are managed on Public Cloud.
Requirements
- Preparing the environment to use the OpenStack API
- Setting the OpenStack environment variables
Instructions
Activation process
This guide section only concerns configurations for private networks.
For pre-existing private networks
To prevent breaking changes during OpenStack Stein and Open vSwitch version upgrades, the "port security" has been set to "False" on existing networks.
You have to use openstack CLI to enable the port security on your existing ports and network.
First, if you want to use firewall rules on private networks you will have to set the "port security" property as "True":
Then, you will need to enable the port security on the port of your service in this network.
As a reminder, to retrieve the port, you can use OpenStack CLI. Execute the command openstack port list --server <server_ID> to retrieve the ports on a given server.
For all services with an active port in this network, enable port security:
Then you can check if a port has port security enabled:
The result should look like the following:
For a new private network
Since the upgrade to the Stein version on OpenStack regions and the new version of Open vSwitch will be done from September 6th, 2022 (Private network port default configuration change), the "port security" flag will be set to "True" by default on any newly created private network.
This will ensure that we stay consistent with the default "True" policy, like on vanilla OpenStack deployments.
Default settings
Each networking port is attached to a security group which contains some specific rules.
The "default" security group contains the following rules:
The return shows that all connections are allowed for any protocol and in both directions.
As a consequence, all the network ports (public and private) will allow every connection when you start an instance.
Managing your private firewall rules
Adding rules
If you want to configure specific rules, you need to create a new security group and associate your network port with it. We advise not changing the default security group. This is to keep access to your instance under all circumstances (e.g. in rescue mode).
Use this command to create the group:
This example security group has only egress rules which means no ingress communication will be allowed.
To add a rule for SSH connections for example, you can use this command:
Enter the following command to associate your security group with your port:
Go further
Join our community of users.