skip to Main Content

I have created one ec2 centos instance and then launched another one from that but in the second one , I have disables the public IP so it doesn’t have a public IP address.

The instances are in same subnet having the same security group, and roles. The first instance have ínternet access but the second one doesn’t have. Is this related to assigning a public IP?

How can I have internet access in an instance without a public IP?

2

Answers


  1. You have two options here:

    [1] The first option is to use Elastic IP: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html

    [2] If you want to have an Internet access without public IP, you need to provision a NAT Gateway and configure route to it.

    People generally do this, they create a VPC, create two subnet in it (one Public and One Private), in the Private subnet they launch their instances, and in the public subnet they create a NAT Gateway, and configure the route in the route table so that the instances in the private subnet have a route to internet via NAT Gateway.

    [1] NAT Gateway: https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html

    Login or Signup to reply.
  2. 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. The NAT gateway or NAT instance allows outbound communication but doesn’t allow machines on the Internet to initiate a connection to the privately addressed instances.

    For VPCs with a hardware VPN connection or Direct Connect connection, instances can route their Internet traffic down the virtual private gateway to your existing datacenter. From there, it can access the Internet via your existing egress points and network security/monitoring devices.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search