Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Source security group isn't working as expected in AWS

I have an EC2 node, node1 (security group SG1) which should be accessible from another EC2 node, node2 (security group SG2) on port 9200. Now, when I add an inbound rule in SG1 with port 9200 and specify SG2 as source in Custom IP section, I can't access node1 from node2. On the other hand, if I specify an inbound rule in SG1 with source as 0.0.0.0/0 or IP of node2, it works fine. What is wrong in my approach?

like image 424
theharshest Avatar asked Jun 15 '14 18:06

theharshest


People also ask

When you specify a security group as the source or destination for a rule The rule affects?

10.10, and another security group that allows access to port 22 from everyone, everyone will have access to port 22 on the instance. Show activity on this post. When you specify a security group as the source or destination for a rule, the rule affects all instances associated with the security group.

What is source in security group AWS?

The source can be a range of addresses (for example, 203.0. 113.0/24), or another VPC security group. By specifying a VPC security group as the source, you allow incoming traffic from all instances (typically application servers) that use the source VPC security group.

Are AWS security Groups Deny by default?

Your AWS account automatically has a default security group for the default VPC in each Region. If you don't specify a security group when you launch an instance, the instance is automatically associated with the default security group for the VPC.


1 Answers

Are you attempting to connect to node1's public or private address? From the documentation:

When you specify a security group as the source or destination for a rule, the rule affects all instances associated with the security group. For example, incoming traffic is allowed based on the private IP addresses of the instances that are associated with the source security group.

I've been burned on this before by trying to connect to an EC2 instance's public address... sounds very similar to your setup, actually. When you wire up the inbound rule so that the source is a security group, you must communicate through the source instance's private address.

Some things to be aware of:

  • In EC2 Classic, private IP addresses can change on stop/start of an EC2 instance. If you're using EC2 classic you may want to look into this discussion on Elastic DNS Names for a more static addressing solution.
  • If you set up your environment in VPC, private IP addresses are static. You can also change security group membership of running instances.
like image 100
Anthony Neace Avatar answered Sep 21 '22 12:09

Anthony Neace