Amazon AWS SDK Guide de l'utilisateur Page 76 : Adding Rules to Your Security Group

/ 155
Table des matières

Adding Rules to Your Security Group

Use the following procedure to add a rule to allow inbound traffic on TCP port 3389 (RDP). This enables
you to connect to a Windows instance. If you're launching a Linux instance, use TCP port 22 (SSH)
instead.

Tip

You can get the public IP address of your local computer using a service. For example, we
provide the following service:
http://checkip.amazonaws.com/
. To locate another service that
provides your IP address, use the search phrase "what is my IP address". If you are connecting
through an ISP or from behind your firewall without a static IP address, you need to find out the
range of IP addresses used by client computers.
The examples in this section follow from the examples in the previous sections. They assume that
mySG
is an existing security group.

To add a rule to a security group

1.
Create and initialize an
IpPermission
object.
string ipRange = "0.0.0.0/0";
List<string> ranges = new List<string>() {ipRange};
var ipPermission = new IpPermission()
{
IpProtocol = "tcp",
FromPort = 3389,
ToPort = 3389,
IpRanges = ranges
};
IpProtocol
The IP protocol.
FromPort
and
ToPort
The beginning and end of the port range. This example specifies a single port, 3389, which is
used to communicate with Windows over RDP.
IpRanges
The IP addresses or address ranges, in CIDR notation. For convenience, this example uses
0.0.0.0/0
, which authorizes network traffic from all IP addresses.This is acceptable for a short
time in a test environment, but it's unsafe in a production environment.
2.
Create and initialize an
AuthorizeSecurityGroupIngressRequest
object.
var ingressRequest = new AuthorizeSecurityGroupIngressRequest();
ingressRequest.GroupId = mySG.GroupId;
ingressRequest.IpPermissions.Add(ipPermission);
GroupId
The ID of the security group.
IpPermissions
The
IpPermission
object from step 1.
3.
(Optional) You can add additional rules to the
IpPermissions
collection before going to the next
step.
Version v2.0.0
72
AWS SDK for .NET Developer Guide
Tutorial: Creating Amazon EC2 Instances

Fichier PDF · ·

Imprimer

Imprimer le document

Partage

Questions sur Amazon AWS SDK

Pas encore de questions sur ce manuel. Posez la première.

Poser une question

Nous répondons à partir du manuel et indiquons la page. La question est publiée sur le site après vérification.

Toutes les questions et réponses ›

Produits connexes et manuels pour Logiciel Amazon AWS SDK