Using Network Security
Topics
This section describes how to use Amazon EC2 network security.
Note | |
---|---|
In addition to these examples, you can maintain your own firewall on any of your instances. This can be useful if you have specific requirements not met by the Amazon EC2 distributed firewall. |
API Overview
This section provides a brief overview of each operation.
-
CreateSecurityGroup—Creates a new security group for use with your account.
-
DescribeSecurityGroups—Returns information about security groups associated with your account.
-
DeleteSecurityGroup—Deletes security groups associated with your account.
-
AuthorizeSecurityGroupIngress—Adds permissions to a security group.
-
RevokeSecurityGroupIngress—Revokes permissions from a security group.
Creating a Security Group
This section describes how to create a security group.
AWS Management Console
To create a security group
-
Log in to the AWS Management Console and click the Amazon EC2 tab.
-
Click Security Groups in the Navigation pane.
The console displays a list of current security groups.
-
Click Security Group.
The Security Group dialog box appears.
-
Configure the following settings and click Create.
- Security Group Name
- Security Group Description
Amazon EC2 begins creating the security group.
Describing Security Groups
This section describes how to view currently configured security groups.
AWS Management Console
To view security groups
-
Log in to the AWS Management Console and click the Amazon EC2 tab.
-
Click Security Groups in the Navigation pane.
The console displays a list of security groups that belong to the account.
-
To view more information about a security group, including its rules, select it.
Adding a Security Group Rule
This section describes how to add a rule to a security group.
AWS Management Console
To add a rule to a security group
-
Log in to the AWS Management Console and click the Amazon EC2 tab.
-
Click Security Groups in the Navigation pane.
The console displays a list of security groups that belong to the account.
-
Select a security group.
Its rules appear in the lower pane.
-
To add a rule, provide the following:
- Protocol
- From Port
- To Port
-
Then, select from the following:
-
To allow access from other instances in a security group, enter the security group name in the Connection Source field.
-
To configure this rule to apply to an IP address range, enter the CIDR range in the Connection Source field. For example, enter 0.0.0.0/0 to allow all IP addresses to access the specified port range. Enter an IP address or subnet to limit access to that one computer or network, for example 92.23.32.51/32.
-
-
Click Save.
The new rule is created and applied to all instances that belong to the security group.
Command Line Tools
To add a rule to a security group
-
Enter the following command:
PROMPT>
ec2-authorize
group
[-Pprotocol
] (-pport_range
| -ticmp_type_code
) [-usource_group_user
...] [-osource_group
...] [-ssource_subnet
...]Amazon EC2 returns an elastic IP address similar to the following:
PERMISSION default ALLOWS tcp 22 22 FROM CIDR 126.52.1.130/32
Delete a Security Group Rule
This section describes how to delete a security group rule.
AWS Management Console
To delete a security group rule
-
Log in to the AWS Management Console and click the Amazon EC2 tab.
-
Click Security Groups in the Navigation pane.
The console displays a list of security groups that belong to the account.
-
Select a security group.
Its rules appear in the lower pane.
-
To delete a rule, click its Remove button.
Amazon EC2 deletes the security group rule.
Command Line Tools
To delete a security group rule
-
Enter the following command:
PROMPT>
ec2-revokegroup
[-Pprotocol
] (-pport_range
| -ticmp_type_code
) [-usource_group_user
...] [-osource_group
...] [-ssource_subnet
...]Amazon EC2 returns output similar to the following:
PERMISSION webservers ALLOWS tcp 80 80 FROM CIDR 205.192.0.0/16
Delete a Security Group
This section describes how to delete a security group.
AWS Management Console
To delete a security group
-
Log in to the AWS Management Console and click the Amazon EC2 tab.
-
Click Security Groups in the Navigation pane.
The console displays a list of security groups that belong to the account.
-
Select a security group and click Delete.
A confirmation dialog box appears.
-
Click Yes, Delete.
Amazon EC2 deletes the security group.
Example
This section provides examples of configuring security groups using the command line tools.
Modifying the Default Group
This example shows Albert modifying the default group to meet his security needs.
Albert Modifies the Default Group
1 |
Albert launches a copy of his favorite public AMI.
|
2 |
After a little wait for image launch to complete. Albert, who is a cautious type, checks the access rules of the default group.
Albert notices that it only accepts ingress network connections from other members of the default group for all protocols and ports. |
3 |
Albert, being paranoid as well as cautious, uses the Linux and UNIX
|
4 |
Albert decides he should be able to SSH into his instance, but only from his own machine.
|
5 |
Albert repeats the Linux and UNIX
Albert is happy (or at least less paranoid). |
Creating a Three-Tier Web Service
Mary wants to deploy her public, failure resilient, three-tier web service (web, application, and database servers) in Amazon EC2. Her grand plan is to have her web tier start off executing in seven instances of ami-fba54092, her application tier executing in twenty instances of ami-e3a5408a,and her multi-master database in two instances of ami-f1a54098. She's concerned about the security of her subscriber database, so she wants to restrict network access to her middle and back tier machines. When the traffic to her site increases over the holiday shopping period, she adds additional instances to her web and application tiers to handle the extra load.
Launch Process
1 |
First, Mary creates a group for her Apache web server instances and allows HTTP access to the world.
|
2 |
Mary launches seven instances of her web server AMI as members
of the
|
3 |
Being as paranoid as Albert, Mary uses the Linux and UNIX
|
4 |
Mary verifies her web server can be reached.
Mary can reach her web server. |
5 |
Mary creates a separate group for her application server.
|
6 |
Mary starts twenty instances as members of
|
7 |
Mary grants network access between her web server group and the application server group.
|
8 |
Mary verifies access to her app server is restricted by port scanning
one of the application servers using the Linux and UNIX
|
9 |
Mary confirms that her web servers have access to her application servers.
|
10 |
Mary repeats these steps to create the database server group and to grant access between the application server and database server groups. |