AWS NAT Gateway Public IP Address for Whitelisting with Public Subnet

1.6k views Asked by At

I have an EC2 instance in a public subnet and I assigned an EIP to the instance and the IP address is Whitelisted to reach my company's network. The Instance must have a public IP address but I don't want to use EIP here. Whenever I restart the server the IP address is changing so I thought If I create a NAT Gateway and arrange the routeing table to use connect my company's network but when I do that I cannot reach the instance. NAT Gateway for the private network for but is there a way to set a static IP address to reach some places?

Default settings for the route table

enter image description here

Setting use NAT Gateway by default access did not work

enter image description here

Adding a new route for the company network did not work

enter image description here

1

There are 1 answers

2
Cargo23 On

To have a static IP address within AWS, you must use an Elastic IP. Even if you use a NAT Gateway, it consumes an EIP.

From the docs:

You must also specify an Elastic IP address to associate with the NAT gateway when you create it.