Forum Discussion
Get ClientIP Address Behind LoadBalancer
Hi,
I am facing an issue to capture the actual IP address of the customers. The Web application is developed in ASP.NET 2.0 version (IIS version is 6.0) and it is hosted in Windows 2003 server behind the F5 Load Balancer.
I have tried to capture the customer IP address through the REMOTE_ADDR server variable, however it is capturing the actual IP address. I have also tried the below server variables and they are not also working either,
- HTTP_X_FORWARDED_FOR
- HTTP_USER_AGENT
- HTTP_CLIENT_IP
- HttpContext.Current.Request.UserHostAddress
I have also tried the solutions mentioned in the link https://devcentral.f5.com/blogs/us/...ws-servers and tried the below steps,
1. Downloaded the file and transferred the dll from \x64\Release folder in a new folder of the server C:\ISAPIFilters.
2. Right clicked on the IIS and select Properties. Then selected the "ISAPI Filters" tab. From there clicked the "Add" button and entered "F5XForwardedFor" for the Name and the path to the file "c:\ISAPIFilters\F5XForwardedFor.dll" to the Executable field. Clicked Ok.
However found that the Status of the Filter is showing as "NOT LOADED" in the IIS.
Also to confirm you that I am receiving NULL values in the X-Forwarded-For Server variable.
Please advise.
Thanks and Regards,
Aniket
- Kevin_StewartEmployeeYou must enable the X-Forwarded-For header in the HTTP profile (Insert X-Forwarded-For) for the LTM to auto-inject the header. Also, depending on how you have the virtual server configured, you may either be seeing the BIG-IP's self-IP (SNAT enabled) address or the client's IP (SNAT disabled). If you require SNAT then you can:
when HTTP_REQUEST { HTTP::header insert CLIENTIP [IP::client_addr] }
- Aniket_129589NimbostratusThanks Kevin for your reply. I am trying this and would confirm you.
- Aniket_129589NimbostratusHi Kevin,
- Aniket_129589Nimbostratus
Hi Kevin,I have checked with the Network team who deals with the F5 configuration details and they have provided the below response,In answer to your question about ‘Insert X-Forwarded For’ feature, this configuration is relevant if SNAT is used in VIP configuration. SNAT feature is not in used (not required) in the existing configuration, SNAT is required if the sever gateway is not the F5 (for these application severs the gateway is F5). SNAT modifies the source IP of the packets that are sent to the pool members so that the return traffic is sent to the F5, and not directly to the user/client that initiated the request.When the F5 system translates the source IP address of the incoming packet from the client to the SNAT address, the web server sees the request as originating from the SNAT address, not the original client IP address. If the web servers are required to log the original client IP address for requests, the SNAT address translation behavior can become problematic.This is where ‘Insert X-Forwarded For’ comes in. I hope this clarify your query.Please could you advice if there anything to resolve this issue?Many Thanks and Regards,Aniket - Kevin_StewartEmployeeFirst, inserting the X-Forwarded-For header is just ONE method for getting the client IP to the server if SNATting. There are definitely other reasons to enable it and other ways to do it. In any case, just to be clear, you only need one of the above techniques: XFF header or iRule. If you use the iRule, based on the example above you'd be looking for the HTTP_CLIENTIP header within your ASP.NET pages. If you're still not seeing the header, or any header with the client IP, the first thing I would do is capture the traffic between the BIG-IP and server using TCPDUMP. Example:
- Aniket_129589Nimbostratus
Thanks Kevin for your continuous help on this.
This is just to inform you that we are using the below piece of codes to track the customer IP addresses.
string _custIP = null; _custIP = HttpContext.Current.Request.ServerVariables["HTTP_CLIENT_IP"]; if (String.IsNullOrEmpty(_custIP)) { _custIP = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; } if (String.IsNullOrEmpty(_custIP)) { _custIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; } Customer IP1 = _hrHttpRequest.ServerVariables["REMOTE_ADDR"]; Customer IP2 = _custIP ; Customer IP3 = _hrHttpRequest.UserHostAddress.ToString() ; Customer IP4 = _hrHttpRequest.ServerVariables["HTTP_X_FORWARDED_FOR"];
- Kevin_StewartEmployee
- Aniket_129589Nimbostratus
Hi Kevin,
Apologies for the delay in reply. This is just to inform you that we are trying to capture the IP addresses of the customers from the website in Emails.
I have spoken with the Network Team who manages the F5 settings and they have advised the below after their investigation,
“When we receive the emails from the customers from the website, the IP address of these emails originate from different IP address that the same customer is accessing the website.
This has no bearing with the LTM configuration or behavior.
When a user sends you an email, you are most likely seeing the IP address of their SMTP server, or the webmail server from which they sent you the email. This is in almost all cases going to be different from the IP address the client actually has on the public Internet, which you can find by for instance browsing to http://myip.dk . Furthermore, the IP address you will see on the LTM will depend on whether or not any further address translation is taking place between the client and the LTM.”
Could you please advice can’t we track the actual IP address of the customer in the Email?
Thanks and Regards, Aniket
- Kevin_StewartEmployee
In short, probably not. There would have to be a client side mechanism to send that information in the SMTP payload. By the time it got to the LTM it would be too late.
- Aniket_129589Nimbostratus
Thanks Kevin for the confirmation.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com