EC2 access to internet in private subnet

0

if EC2 in private subnet wants to access internet .The Natgateway in public subnet should be attached to EIP(elastic ip) or it can get internet access thorough IG(Interet gateway) which is basically right approach

Ajit
質問済み 2ヶ月前207ビュー
3回答
1

Correct. And you’ll need a route from private subents to the NAT gateway. A useful link https://docs.aws.amazon.com/AmazonECS/latest/bestpracticesguide/networking-outbound.html

profile picture
エキスパート
回答済み 2ヶ月前
1

To allow EC2 instances in a private subnet to access the internet, the common approach is to route their traffic through a NAT Gateway. Here's how it typically works: NAT Gateway in Public Subnet: You deploy a NAT Gateway in a public subnet, which has a route to the internet through an Internet Gateway (IGW).

Elastic IP (EIP): The NAT Gateway requires an Elastic IP (EIP) to provide a static public IP address for outbound internet traffic. The EIP is automatically assigned to the NAT Gateway during creation.

You can refer to this AWS documentation :- https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html

Hope it clarifies and if does I would appreciate answer to be accepted so that community can benefit for clarity, thanks ;)

profile picture
エキスパート
回答済み 2ヶ月前
profile picture
エキスパート
レビュー済み 2ヶ月前
0

You should have both.

The route table of the private subnet where the EC2 instances are located should have the NAT gateway in the public subnet as the next hop.

The route table of the public subnet where the NAT gateway is located should have the internet gateway as the next hop.

The NAT gateway should also have an elastic IP attached to it which is the IP that will be seen by the internet (the internet gateway by itself doesn't hold a public IP).

AWS
回答済み 2ヶ月前
profile picture
エキスパート
レビュー済み 2ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ