AWS Advanced Networking - Troubleshooting Linux Instance Connection Issue

Diagnosing Connection Issue with a Linux Instance - AWS Certified Advanced Networking Specialty Exam

Prev Question Next Question

Question

You are trying to diagnose a connection issue with a Linux instance.

The instance is assigned a public IP and is in the public subnet.

You can also see that the Internet gateway is attached, and the route tables are in place.

You SSH into the instance from a bastion host.

You then do an ifconfig and see that the interface does not display the public IP address.

What should be done next to check the issue?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Answer - C.

The public IPv4 address is displayed as a property of the network interface in the console.

But it's mapped to the primary private IPv4 address.

Therefore, if you inspect the properties of your network interface on your instance, for example, through ifconfig (Linux) or ipconfig (Windows), the public IPv4 address is not displayed.

To determine your instance's public IPv4 address from within the instance, you can use instance metadata.

In such a scenario, all other options become invalid.

For more information on using Instance addressing, please refer to the "Note" section on page 715 on below URL.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-ug.pdf

When diagnosing a connection issue with a Linux instance that is assigned a public IP and is in a public subnet, if you SSH into the instance from a bastion host and do an ifconfig command, and you see that the interface does not display the public IP address, the next step is to check the metadata for the instance.

The metadata for the instance contains information about the instance, including its public IP address. To check the metadata, you can use the following command:

ruby
curl http://169.254.169.254/latest/meta-data/

This command will return a list of available metadata categories for the instance. To get the public IP address, you can use the following command:

ruby
curl http://169.254.169.254/latest/meta-data/public-ipv4

This command will return the public IP address for the instance.

If the metadata does not show a public IP address, the next step is to assign a public IP address to the interface. This can be done by either assigning an Elastic IP to the interface or by assigning the public IP directly to the interface.

Assigning an Elastic IP to the interface is recommended because it provides a static IP address that can be associated with the instance even if the instance is stopped and started again. To assign an Elastic IP to the interface, you can use the following command:

css
aws ec2 associate-address --instance-id instance_id --public-ip ip_address

Where instance_id is the ID of the instance, and ip_address is the Elastic IP address to be associated with the instance.

In summary, to diagnose a connection issue with a Linux instance that does not display the public IP address in the interface, check the metadata for the instance, assign a public IP address to the interface if needed, and assign an Elastic IP to the interface for a static IP address.