Security Groups¶
Security Groups Introduction¶
Security groups are basically whitelists applied to the virtual network interfaces to control the inbound and outbound traffic. Traffic that does not match any rule in the security group will be discarded. Security group rules are realized using stateful session tracking. This means that you must specify a rule only for the direction in which the session is initiated, with the other direction being implied.
A VPC automatically includes a default security group. Each instance that you launch in your VPC is automatically associated with the default security group unless you specified a different security group when you launched the instance.
When you create a security group, you must provide it with a name and a description. The following rules apply:
Names and descriptions can be up to 255 characters in length.
For AWS compatibility, names and descriptions are limited to the following characters: a-z, A-Z, 0-9, spaces, and ._-:/()#,@[]+=&;{}!$*.
A security group name cannot start with sg-.
A security group name must be unique within the VPC.
For each security group, you include one set of rules that controls the inbound traffic to the instances, and a separate set of rules that controls the outbound traffic from the instances.
The following are the basic components of a security group rule in a VPC:
For inbound rules only - The source of the traffic and the destination port or port range. The source can be another security group, an IPv4 or IPv6 CIDR block, or a single IPv4 or IPv6 address.
For outbound rules only - The destination for the traffic and the destination port or port range. The destination can be another security group, an IPv4 or IPv6 CIDR block, or a single IPv4 or IPv6 address.
Any protocol that has a standard protocol number (click here for a complete list of Protocol Numbers). If you specify ICMP as the protocol, you can specify any or all of the ICMP types and codes.
Creating Security Groups¶
To create a security group:
Nsvigate to Networking > Security Groups. From top toolbar, click Create.
In the Create Security Group dialogue, enter the following information:
Name – name of the security group.
Description (optional) - description of the security group.
VPC - select a VPC with which the security group should be associated.
Near Rules, click Add. For each rule, enter the following:
Internet Protocol Version - select IPV4 or IPV6.
Direction - Select EGRESS for defining a rule for outbound traffic. Select INGRESS for defining a rule for inbound traffic
Protocol - Specify the protocol for which the rule will apply - ‘TCP’, ‘UDP’ or ‘ICMP’. Permit traffic from any protocol by selecting ‘Any’.
Start port and end port
If Protocol = ‘Any’, then leave blank.
If Protocol = ‘TCP’ or ‘UDP’, then enter the port range for the rule.
If Protocol = ‘ICMP’, then enter the ICMP Message Type in the first field and ICMP Code in the second field.
Click OK to create the security group. The new security group appears in the Networking > Security Groups view.
To add another rule, click Add again.
Security Group Operations¶
After creation of a Security Group, it will be displayed in the list in the Networking > Security Group view. The following operations can be performed by selecting a security group from the list, and clicking the appropriate icon.
From top toolbar:
Modify - add or delete rules to the selected security group.
Detach - detach the security group from all associated network interfaces.
Delete - delete the selected security group.
From lower toolbar:
Rules - view rules associated with the selected security group.
VMs - view VM instances associated with the selected security group.
Events - view configuration events (info) or alarms for the route table.