Returning Customers — Login
Call 1.866.720.0208 or contact us
Amazon Web Services (AWS) EC2 security groups serve as firewalls for EC2 servers, for restricting ingress (incoming) communications based on protocol type (TCP, UDP, ICMP), IP address, and ports. Each EC2 server you launch must have at least one assigned security group.
Security groups determine who can communicate with servers that belong to that group. By default, all incoming network traffic to an EC2 server is rejected unless the server belongs to one or more security groups whose rules specifically allow that traffic. With the exception of Amazon Virtual Private Cloud (VPC) security groups, discussed under VPCs, EC2 security groups only affect incoming communications and do not prevent a server from initiating outbound communications.
Table of Contents
Security groups use CIDR-based notation, illustrated in the diagram below, to grant access permissions to servers. For CIDR-based rules, you can also specify the protocol and port range.

Scenario 1: Servers are in the same security group, and the group is not added to itself. The servers are in the same AWS region, though they could be in different availability zones in that region. Servers in the security group establish connections to each other over private IP addresses through the designated opened ports. In this example, instead of designating 0.0.0.0/0 to enable protocol and port access to any IP address, we applied a more restrictive setting (10.0.0.0/8) that still allows these servers to communicate with each other since they are in the same AWS region. (All EC2 servers are assigned a private IP address starting with "10.")

Scenario 2: Each server is assigned a different security group within the same AWS region. In this example, since the servers are not using the same security group, they can only communicate with each other across public IP addresses. However, these servers would be able to communicate over their private IP addresses if the security groups were added to each other (as depicted in Scenario 3).

Scenario 3: Requests are made to a server from outside its AWS region (either from EC2 servers in a different AWS region or servers outside of AWS). A server in a different AWS region is treated the same way as a server outside of EC2. In this example, any server can communicate with the instance in Security Group "A" via its public IP address, over port 3306.
Note: Requests made from EC2 instances in a different AWS region via a private IP address will be redirected to use the public IP address.

Scenario 4: Add a security group to itself. Servers establish connections over private (not public) IP addresses and can use any protocols and ports specified during permissions setup. In this example, all servers in security group "A" can access servers in the same group, using any protocol and port, while the administrator at IP address 1.2.3.4 can access servers in group "A" using port 3306 and the server's public IP address.

Scenario 5: Add a security group to another security group. In this case, servers in the first security group establish connections over private (not public) IP addresses to servers in the other security group using specified ports and protocols. In this example, all servers in security group "B" can access servers in group "A" using any protocol and port combination, while only the administrator at 1.2.3.4 can access servers in group "A" using port 3306 and the server's public IP address.

Scenario 6: Add a security group to another security group with limited protocol and/or port access. Servers establish connections via private (not public) IP addresses but can only use a specific protocol port or range of protocol ports for access. In this example, all servers in security group "B" can access servers in group "A" using TCP over port 3306.

Scenario 7: Restrict access to only receive requests from a server with a specific IP address. This can be especially useful when using Elastic IP (EIP) addresses, when a server will only receive requests from another server using a specific EIP.
