How to open traffic between 2-Ec2 instances via internal private IPs

0

I have 2 ec2 instances that are needed to communicate as backend servers. They are both attached to the same security group which has a inbound rule allowing for all ports on the VPC's CIDR range. So the CIDR range is 172.31.0.0/32 for all ports.

The program is that when I ping instance 1 from instance 2 using the internal IP address, the ping fails. I'm not sure why that fails. Any help would be great.

已提問 1 年前檢視次數 373 次
2 個答案
1

The /32 CIDR range only allows a single host in the range. VPC CIDR ranges are typically between /16 and /24. If you want all hosts associated to the security group to communicate with each other on all ports and protocols you will need to expand the CIDR range to match the CIDR of your VPC (i.e. something like 172.31.0.0/16) or you can self reference the security group id as the source in the rule rather than a CIDR range. See this documentation.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/security-group-rules-reference.html#sg-rules-other-instances

profile pictureAWS
專家
已回答 1 年前
0

/32 mean single IP address. 172.31.0.0/32 won't much with any EC2 instance. You have to create rule for each server. Ex: 172.31.10.5/32 First EC2 172.31.10.6/32 Second EC2

已回答 1 年前
  • What if I know that all the EC2s will be on the same VPC and will all have private IPs within the range of 172.31.0.0? Is there not a way to specify everything within that range?

  • Please see my answer below for a link to AWS docs but the short of it is you need the rule CIDR range to match your VPC CIDR. Assuming your VPC is defined as 172.31.0.0/16 this is what your rule should reflect. Or you can self reference the security group and not deal with CIDR ranges at all.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南