Internet Connectivity Issue: EC2 Instance Cannot Access the Internet

0

Hello,

We are currently experiencing an issue where our EC2 instance cannot connect to the internet. Below are the details of the problem.

Issue Description:

Our EC2 instance cannot connect to the internet. For example, when running the ping google.com command, we experience 100% packet loss. DNS queries fail, and we are unable to install packages using yum.

Troubleshooting Steps Taken:

Verified VPC and subnet settings and configured the internet gateway. Attached the internet gateway to the subnet and set up the route table to route 0.0.0.0/0 traffic to the internet gateway. Reset the network interface on the instance and set the default route. Modified the /etc/resolv.conf file to use DNS servers 8.8.8.8 and 8.8.4.4. Command Output Examples:

Output of ping google.com: lua PING google.com (172.217.167.78) 56(84) bytes of data. --- google.com ping statistics --- 4 packets transmitted, 0 received, 100% packet loss, time 3120ms Output of ip addr show enX0: sql 2: enX0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc fq_codel state UP group default qlen 1000 link/ether 0a:7e:0d:09:56:df brd ff:ff:ff:ff:ff:ff inet 172.31.20.247/20 metric 512 brd 172.31.31.255 scope global dynamic enX0 valid_lft 3420sec preferred_lft 3420sec inet6 fe80::87e:dff:fe09:56df/64 scope link valid_lft forever preferred_lft forever We would appreciate guidance on any additional steps needed to resolve this issue.

Thank you.

Kmall

2 Answers
1

Please verify that your EC2 instance has a public IP address assigned, and that your subnet's Network ACL allows all traffic inbound and outbound (default settings). You can narrow that down later but for now leave it open.

EXPERT
answered 2 months ago
0

Hello,

To troubleshoot why your Amazon EC2 can't access the internet, do the following:

  • Verify that the instance has a public IP address.
  • Verify that the outbound rules of the security group bound to the instance do not block access.

Verify that the instance has a public IP address

If the instance in a public subnet doesn't have a public IP address, then the instance isn't accessible outside the virtual private cloud (VPC) where it resides in. This is true even if the instance has an internet gateway.

To allow the instance connectivity to the internet, allocate an Elastic IP address, and then associate this Elastic IP address with the instance.

If you do not want to provide a public IP for the instance, you can also try adding a NAT Gateway to the VPC, and then change the route for the subnet where your instance is located from the Internet Gateway to the NAT Gateway.

Verify that the outbound rules of the security group bound to the instance do not block access.

The security group for the elastic network interface attached to the instance must have a rule that allows outbound internet traffic (0.0.0.0/0) for your port and protocol.

The following blog links may be helpful to you:

https://repost.aws/knowledge-center/ec2-connect-internet-gateway

answered 2 months ago
profile pictureAWS
EXPERT
reviewed 2 months ago