Search code examples
amazon-web-servicesamazon-ec2amazon-vpc

Internet connection is working for subnet which is not associated with public route table


I have created one VPC in AWS Cloud with 3 public & private subnets. I have attached the Internet gateway to VPC and configured in public route table which has 3 public subnets. However, I don't associated 3 private subnets to private route table. Now, I tried to launch new server from private subnet and SSH to machine, I checked the internet connection. Yes, I can able to see the internet connection to Private machine, even I don't associate this subnet to public route table. How it's happened? Is this happened because of Internet gateway which is attached to VPC level? Can any one please clarify this things?

Note: I'm not using NAT gateway for Private subnets


Solution

  • The definition of a Public Subnet is that is has a Route Table that references an Internet Gateway with a destination of 0.0.0.0/0.

    When a VPC is created, there is a "Main" Route table that is automatically associated with all subnets unless they specifically refer to a different Route Table. It is possible that your private subnets are not associated with the 'Private' Route Table, so it is using the 'Public' Route Table.

    The best way to determine what is happening is:

    • Find your instance
    • In its description, click on its Subnet
    • In the Subnet details, click on the Route Table
    • Check if the Route Table references the Internet Gateway