Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Public IP of AWS Internet gateway [closed]

I would like to know the public IP of AWS internet gateway. My client needs it to do an IP whitelist. How can I get it? My instance is faced to the internet directly and didn't route via any NAT gateway. From my understanding, The public IP should be the elastic IP of EC2 instance, which connects to my client. Can any guy make sure of my understanding?

Thanks

like image 709
WICHPONG KAO-IAN Avatar asked May 29 '20 11:05

WICHPONG KAO-IAN


People also ask

Does AWS Internet gateway have public IP address?

The instance itself doesn't actually 'know' that it has a public IP address / Elastic IP address. Instead, when traffic comes from the Internet destined for the public IP address, the Internet Gateway performs a reverse NAT and sends the traffic to the private IP address of the instance.

How do I find my AWS public IP?

To view the IPv4 addresses for an instance using the consoleOpen the Amazon EC2 console at https://console.aws.amazon.com/ec2/ . In the navigation pane, choose Instances and select your instance. The following information is available on the Networking tab: Public IPv4 address — The public IPv4 address.

Can't access AWS public IP?

To troubleshoot why your Amazon EC2 can't access the internet, do the following: Verify that the EC2 instance meets all prerequisites. Verify that the instance has a public IP address. Verify that a firewall isn't blocking the access.

How do instance without a public IP access the internet?

Instances without public IP addresses can access the Internet in one of two ways: Instances without public IP addresses can route their traffic through a NAT gateway or a NAT instance to access the Internet. These instances use the public IP address of the NAT gateway or NAT instance to traverse the Internet.


Video Answer


1 Answers

You are correct.

An Internet Gateway is a logical connection between a VPC and the Internet. If there is no Internet Gateway, then there is no connection between the VPC and the Internet.

Every Amazon EC2 instance in a VPC has a private IP address. They can optionally also have a public IP address. This can either be a random one assigned when an instance is started, or a static Elastic IP address can be assigned to the instance.

Actually, these public IP addresses are assigned to an Elastic Network Interface (ENI). An instance can have multiple ENIs.

The instance itself doesn't actually 'know' that it has a public IP address / Elastic IP address. Instead, when traffic comes from the Internet destined for the public IP address, the Internet Gateway performs a reverse NAT and sends the traffic to the private IP address of the instance. Similarly, any traffic going from the instance to the Internet Gateway comes from the private IP address of the instance, which the Internet Gateway then forwards as coming from the instance's public IP address.

Thus, the Internet Gateway 'owns' the public IP address, but forwards it to the instance. It's all quite magical, so sometimes it's just easier to imagine as the instance having the public IP address.

One benefit of this method is that an Elastic IP address can be reassigned to another instance and traffic will immediately flow to the new instance without any configuration changes on the 'old' or 'new' instance. They just get traffic via their private IP addresses without knowing that a public IP address was involved.

like image 55
John Rotenstein Avatar answered Oct 18 '22 22:10

John Rotenstein