AWS Advanced Networking Specialty: How to Get Web Server IP Addresses without AWS Console or API Access

How to Get IP Addresses Accessing Your Web Server without AWS Console or API Access

Prev Question Next Question

Question

Your company has a web server hosted on an EC2 Instance.

This is being used along with the AWS Application Load Balancer, Cloudfront and S3

There is a requirement to get the IP addresses accessing the web site.

How can this be managed if no access has been provided to the AWS console or the API.

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Answer - C.

The AWS documentation mentions the following on X-Forwarded headers.

The X-Forwarded-For request header helps you identify the IP address of a client when you use an HTTP or HTTPS load balancer.

Because load balancers intercept traffic between clients and servers, your server access logs contain only the IP address of the load balancer.

To see the IP address of the client, use the X-Forwarded-For request header.

Elastic Load Balancing stores the IP address of the client in the X-Forwarded-For request header and passes the header to your server.

For more information on X-Forwarded headers please refer to the below URL:

http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/x-forwarded-headers.html

In order to obtain the IP addresses accessing the web site, there are a few options available:

A. Use the local metadata on the server to access the logs: EC2 instances can retrieve instance metadata from the metadata service at a local, non-routable IP address. The metadata includes information about the instance, such as the instance ID, instance type, local IP addresses, public IP address, and more. By accessing the metadata, you can retrieve the logs and find the IP addresses accessing the web site. This method can be used if access to the AWS console or API is not available.

B. The access logs should already have this information: The AWS Application Load Balancer, CloudFront, and S3 all provide access logs that can be used to obtain the IP addresses accessing the web site. These logs can be retrieved and analyzed to find the IP addresses. However, it is important to note that this method assumes that access logging is already enabled and configured to capture the necessary information.

C. Add “X-Forwarded For” to the access logs and view the access logs: If the Application Load Balancer is being used, adding the “X-Forwarded For” header to the access logs can provide additional information, including the IP addresses of the clients accessing the web site. This method can be used in conjunction with method B above to provide more detailed information.

D. Convert the Application Load Balancer to a classic load balancer: If the Application Load Balancer is converted to a classic load balancer, the IP addresses of the clients accessing the web site will be available in the access logs. However, it is important to note that this method is not recommended as it involves changing the load balancer configuration, which may have unintended consequences.

In summary, options A, B, and C are all viable options for obtaining the IP addresses accessing the web site, depending on the specific scenario and configuration. Option D is not recommended unless absolutely necessary.