Route traffic from route53 to instances in private subnet - amazon-web-services

I have instances in private subnet connected to a load balancer. NAT gateway is available in public subnet (to provide internet to private subnet). How can we route traffic from route53 to instance in private subnet.

You have to setup application or network load balancers in a public subnet. Then you point your Route53 to your LB, which will in turn direct traffic to your instances in the private subnets.

Related

what is the usage of CIDR notation route rule in aws

I have created a VPC and internet gate way. And attached internet gateway to the vpc. Create two subnets one is public subnet and another is private subnet. And created a route table to route the traffic. In route table added a route rule 0.0.0.0/0 to IGW(internet gatway). To test this I launch a EC2 instance in public subnet. I have generated a public IP address example : (554.6.8.24). Using that IP address do ssh and I am connecting from local machine to EC2 instance.
My question is I am connecting to the EC2 instance from my local machine using public IP. What is the point of adding route rule in 0.0.0.0/0 to IGW(internet gatway) in route table?. With out route rule can I connect to Ec2?
If an Internet Gateway is not present in an Amazon VPC, then that VPC has no connection to the Internet. This can be very useful for creating private networks.
If you want to connect a VPC to the Internet, then you need to:
Create an Internet Gateway for that VPC
Create a Route Table that sends traffic to the Internet Gateway
Attach the Route Table to a Subnet (thereby making that subnet a Public Subnet since it routes to the Internet Gateway)
Put resources inside the Public Subnet (eg EC2 instances)
In contrast, Private subnets do not have a Route Table entry that points to an Internet Gateway. Therefore, those subnets cannot access the Internet. This is an added layer of security to prevent access to private resources.
The only difference between a Public Subnet and a Private Subnet is having the Route Table entry that points to an Internet Gateway. Without that entry, a subnet will remain private.

Is it possible to create a VPC with only a public subnet and NAT for EC2 instances without elastic IPs?

I need to migrate a big cluster of VMs to AWS. Some of these have Public IPs, others only local IPs. Is it possible to create mixed subnetwork of Public and Private IPs within a VPC such that instances with a Public IP access the Internet via an Elastic IP and the Internet Gateway and such that instances that don't have a Public IP go to the Internet over NAT. The local IP instances must be in a single subnetwork such as 192.168.1.0/24.
Is it possible how to do this? and what would be an optimal approach?
By definition, a public subnet has a route to an Internet Gateway. Anything in that subnet that needs to access the Internet will need a public IP (not necessarily an Elastic IP, just a public IP) assigned to it.
If a subnet's traffic is routed to an internet gateway, the subnet is known as a public subnet.
Similarly, by definition a private subnet is a subnet without an Internet Gateway, which relies on route to a NAT Gateway to access the Internet.
If a subnet doesn't have a route to the internet gateway, the subnet
is known as a private subnet.
Per your question, no, there's no way to have a single route table that routes traffic to both an Internet Gateway and a NAT Gateway based on the presence or lack of a public IP address on the source server.

AWS VPC - Private subnet added to the public route table attached to internet gateway

Hope you are all doing good.
AWS allows us to attach a private subnet (created in a Customer VPC) with a route table having route to the internet via internet gateway. Does it make any difference to the instance launched in the private sub-net? or it is as good as having the private subnet not linked to the route table having route to the internet
Regards
AJ
A subnet is not private if it has routes to/from the internet. The instances launched in a private subnet cannot access the internet and cannot be reached from the internet.
For e.g if you have a database instance and you don't want anyone but the instances to access the instance, you can launch the instance in the private subnets.
Also if you want the instances in the private subnet to access internet, you need to setup a Nat Gateway (or a Nat Instance)
Hope this helps
First, we need to know what's the difference between a public subnet and a private subnet.
Public Subnet means this subnet has an Internet Gateway attached to it.
Private Subnet means this subnet has a NAT Gateway attached to it.
And the Internet Gateway can have both inbound and outbound but the NAT only can have outbound to the Internet.
And A NAT will be built in a public subnet but attach to a private subnet.
You can have lots of public/private subnets at the same time and attached NAT or IGW for them, but the IGW only can have one in each VPC.
In some use cases, we will not attach any kinds of NAT and IGW for a subnet. that's because it might be a database subnet and won't expect it to communicate with the Internet.
Normally, we will use a subnet with NAT attached for our application such as EC2 or ECS, Internal Load Balancers.
On the other hand, we will use a subnet with IGW attached for Internet-facing Load balancers, Nginx, Apache.
AWS VPC Design:
https://aws.amazon.com/tw/answers/networking/aws-single-vpc-design/
I think the hidden magic here is that the instance in the private subnet needs a public IP to communicate with outside, we never ever think this an issue in our lives. When our computer connect to the router, it get access to internet without any issue, why it works so smoothly? All because the router handles everything for us, including allocating a private IP for us, making recursively DNS query for us, and the most important, translating the private IP using the router's public IP so that our computer can communicate with the outside bidirectionally.
Let's go back to this AWS VPC scenario, you attached a route table with a default route to the Internet Gateway to your private subnet, which makes it looks like a public subnet. However, the instances still have no public IPs, and, not like our router, the Internet Gateway of AWS VPC doesn't do NAT works! So how can an instance with no public IP and no NAT access the internet? It's impossible.

I can't connect through RDP to my EC2 Windows instance

NETWORK:
I have a private subnet and a public subnet. A VPC with IG attached. There is a NAT Gateway in the public subnet. I also have 2 route table, the public route table routes everything to the IG, the private route table routes everything to the NAT Gateway.
EC2:
My EC2 Windows instance is in the private subnet with a EIP and a Public DNS. It has a security group that allows all fron internet inbound/outbound but i cant even ping neither rdp
All the machine or instances in the private subnet cannot be connected externally hence the name private subnet. If you want to connect to your instance externally you must place it in the public subnet (the subnet that is connected to the internet gateway). Eventhough, you attach an elastic ip (which is a public ip) but it is routed through a NAT. The EIP must go through the internet gateway only.
If you really want to connect you need to VPN to your VPC (using AWS VPC VPN) and then RDP to your instance. Or have a gate instance in your public subnet.
Verify that the route table for the subnet has a route that sends all traffic destined outside the VPC to the internet gateway for the VPC. For more information, see Creating a Custom Route Table (Internet Gateways) in the Amazon VPC User Guide.

pass traffic between private and and public subnet by Nat Gateway

is it possible to pass traffic between one resource in private subnet and another one in public subnet?
for example; the caching servers in front of NLB. the NLB is in public subnet and the cache instances are in private subnet with NAT gateway.
All resources within the same AWS VPC can communicate with each other. It doesn't matter if some of them are Public or Private subnets, they can all communicate with each other.
You should use the private IP address to communicate with another resource in the same VPC.