Shorter version of my questions:
- If an instance has a public ip but it is located in a private subnet, can it receive inbound traffic? (assume no firewall blocks it)
- When there isn’t route for internet gateway in a route table, does this mean (1) it just drops outbound traffic to the internet or (2) there isn't a “connection” between the route table and the internet gateway at all, therefore, it also doesn’t receive inbound traffic from the internet? If (2) is the case, can you elaborate on how this “connection” is established?
Longer version of my question:
I am watching a course on Whizlab where the instructor built the network structure in the image below to demonstrate how transit gateway works for private subnets. I am confused about what stops green ec2_1
from accessing blue ec2_2
.
He tested this inaccessibility by:
- ssh into
green ec_1
- then, ping
blue ec2_1 private ip
, success - then, ping
blue ec2_2 private ip
, no response
Then he says, the ping to blue ec2_2 private ip
won’t work because “we have no route from the green instance to a blue instance in private subnet”.
However, I think the reasons should be “we have no route from the blue instance in the private subnet to a green instance”. Basically, I think what fails the ping is the outbound traffic in blue private subnet, not the inbound.
More of my current understanding:
- Any route table in a vpc can receive any traffic being forwarded to it. It sends the traffic to the next hop called
target
given thedestination
contained in the packet. If it doesn’t have a givendestination
, it simply drops the traffic. - The second testing ping can route into
blue ec2_2
based on the “20.0.0.0/16=>local” route inblue route_table_2
(Sorry for the small image! Too many details to include, feel free to open it in a new tab!)
I found this post helpful after posting this question. That post explains how NAT and private subnet work in vpc and why it is possible for an instance with public ip inside private subnet to receive internet traffic but not send out useful outbound traffic.