1
votes

For example, when I deploy two AWS EC2 instances in same VPC and same subnet, that two instances connect through internet using public IP? I already know that traffic flows referring to route table and my current route table sends all traffic except between private IP to internet gateway. By the way, I wonder if those "all traffic except between private IP" includes AWS public IP. In this situation, Does AWS automatically route traffic just inside VPC or not??

2
DNS resolution from inside the VPC of EC2 instance hostnames yields private IP addresses, and hence traffic between EC2 instances within the VPC is privately routed within the VPC.jarmod

2 Answers

2
votes

Yes, all traffic between the EC2 instances within the same VPC will be routed using internal, private IP obtained from the private DNS.

You can find more in the VPC international DNS here https://docs.aws.amazon.com/vpc/latest/userguide/vpc-dns.html#vpc-dns-viewing

Best, Stefan

2
votes

The question is a little confusing, but I think I understand. Quick rephrasing: How does traffic route for EC2 Instances.

  1. If traffic has to go to the internet, then it will. There are techniques where this is done on purpose, such as hairpinning, and if this is your intention, there shouldn't be any problem with doing something like this.

  2. AWS has a 'Backend' (Sometimes called a backbone) network. All communication to EC2 Instances, or Amazon Services in General, should be routed on the AWS Backbone.

I had a little trouble locating a doc with the exact wording, but this doc covers it a bit. Please remember that the AWS Backbone is fast, so it is a good thing to use it.

https://docs.aws.amazon.com/vpc/latest/userguide/how-it-works.html