luqiang tian
luqiang tian

Reputation: 67

How an EC2 access another EC2 in the same VPC using public IP?

I find this Can an AWS private IP address server connect to a public IP address server that is in the same VPC?

Both my two EC2s have public IP, and work fine, I have no NAT instance.

How do I Make sure the security group of the server with public IP accepts inbound traffic from the VPC NAT

Upvotes: 1

Views: 3899

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269340

Your question is a bit unclear about your current configuration, but let's say you have:

  • An Amazon VPC with one public subnet
  • Two instances both in the public subnet
  • They each have Public IP addresses assigned

Yes, the two instances can communicate directly with each other. It is best that they communicate via the private IP address -- this way, the traffic remains totally within the VPC.

If they communicate via their public IP addresses, then the traffic goes out of the VPC to the AWS edge of the Internet, then back into the VPC. Such traffic is charged at 1c/GB.

All instances within a VPC can communicate directly with each other via their private IP addresses, even if they are in different subnets. However, the Security Group will need to be configured to accept the incoming traffic. This can be configured based on the IP address of the source instance, or by reference to a security group that is associated with the source instance.

Upvotes: 6

Related Questions