Skip to main content

Security Group

A Security Group controls traffic to connected resources using inbound and outbound rules. For example, by associating a security group with the network interface of a BCS instance, you can regulate the inbound and outbound traffic of that instance, enhancing security by governing the traffic flows.

Policies for inbound and outbound traffic can be configured independently, allowing for the control of traffic based on protocols and port numbers. By implementing this approach, you can improve the safety of your network by allowing only necessary communications and blocking unnecessary traffic.

Understanding security groups work

Security Groups function based on the following principles:

OperationDescription
Whitelist-basedSecurity groups only permit traffic that matches defined rules.
State managementSecurity groups are stateful, meaning:
- Responses to inbound traffic are automatically allowed, regardless of outbound rules, and vice versa.
- This statefulness ensures return traffic is permitted for sessions initiated by allowed requests.
Multiple instance connectionsA single security group can be applied across multiple instances for consistent security policies.
Multiple security group connectionsMultiple security groups can be applied to one instance.
- A security group with multiple connected security groups allows policies from all connected security groups.
Copying multiple security groupsSecurity groups with the same inbound/outbound rules can be copied to create new ones.

Security group basics

  • Security groups use a whitelist-based approach, denying all traffic not explicitly allowed by the policies. Therefore, you need to set policies to allow desired traffic.
  • Security groups are stateful. Responses to inbound traffic are allowed to exit the instance regardless of outbound rules, and vice versa.
  • Associating multiple security groups with a single resource, a single policy set is formed, which is used to determine access permissions.
  • Adjustments to a security group's rules are dynamically applied to all associated resources. However, changes do not take effect immediately in the security group; only packets are allowed until existing connections timeout.
  • There are limits on the number of security groups, rules per group, and group associations per network interface, detailed in the the Pricing and Quotas for more details.

Security group policies

Security group policies dictate allowed inbound and outbound traffic for associated resources, based on the following criteria:

ItemDescription
ProtocolProtocol to apply policy to
- TCP, UDP, ICMP, ALL.
Source or DestinationFor inbound rules, the source IP range; for outbound, the destination range.
Port numberThe port number(s) the rule applies to.
Policy DescriptionA description of the policy.

Examples

The policies you add to a security group often depend on the purpose of the security group. The following table describes example policies for the security group associated with the web server. The web server can receive HTTP and HTTPS traffic from IPv4 and send SQL or MySQL traffic to the database server.

Inbound rules

ProtocolSourcePort numberDescription
TCP0.0.0.0/080Allows HTTP from any IPv4 address
TCP0.0.0.0/0443Allows HTTPS from any IPv4 address
TCPPublic IPv4 address range of the network22Allow SSH from specific network IPs
TCPPublic IPv4 address range of the network3389Allow RDP from specific network IPs

Outbound rules

ProtocolDestinationPort numberDescription
TCPSQL server IP range1433Allows access to Microsoft SQL Server
TCPMySQL server IP range3306Allows access to MySQL
tip
  • To avoid configuration errors, it's advised to limit the number of security groups and tailor each to resources with similar security needs.
  • When adding inbound rules to allow access to BCS instances on ports 22 (SSH) or 3389 (RDP), grant access only to specific IP address ranges.
  • Avoid opening large port ranges. Set each port to allow access restricted to source or destination requiring that port.

Default security group

Every project automatically has a default security group named default, with the following inbound and outbound rules. The default security group can be modified and used as needed, but cannot be deleted.
The policies of the default security group are as follows.

Inbound rules

ProtocolSourcePort numberDescription
TCP@defaultALL     Allows inbound traffic from resources in the same security group

Outbound rules

ProtocolDestinationPort numberDescription
ALL0.0.0.0/0ALL     Allows all outbound traffic

Custom security group

Custom security groups can be created to reflect specific roles within your infrastructure, each with a unique name within the VPC. The following are the default rules of a security group.

Inbound rules

No predefined rules (no traffic allowed)

Outbound rules

ProtocolDestinationPort numberDescription
ALL0.0.0.0/0ALL     Allows all outbound traffic
caution

If only custom security groups are used, instances in the VPC will be unable to acquire metadata and thus inaccessible. To enable metadata acquisition, add the following outbound rules:

ProtocolDestinationPort numberDescription
TCP169.254.169.0/2480      Required to acquire metadata