FNowak_29320
May 26, 2014Nimbostratus
"bad IP address format" errors when using geolocation iRule
Hey guys,
I am currently working on an iRule that shall append an URL parameter called "isCountryEMD=yes" whenever US or CA users try to access my website. I am using multiple domains where some of them are using a CDN and some of them don't. To cover both scenarios I am checking the geolocation with either IP::client_addr or the HTTP header "True-Client-IP" which is being set by my CDN, containing the origin IP address of my visitors:
when HTTP_REQUEST {
set True_Client_IP "[HTTP::header "True-Client-IP"]%1"
if { (([whereis [IP::client_addr] country] equals "US") or ([whereis [IP::client_addr] country] equals "CA") or ([whereis $True_Client_IP country] equals "US") or ([whereis $True_Client_IP country] equals "CA")) }
{
if { [HTTP::uri] contains "?"}{
HTTP::uri "[HTTP::uri]&isCountryEMD=yes"
log local0. "GEOREDIRECT - URL: [HTTP::host][HTTP::uri] - IP Remote: [IP::client_addr] - True-IP: $True_Client_IP"
pool pool_ebiz_prod_80
} else {
HTTP::uri "[HTTP::uri]?isCountryEMD=yes"
pool pool_ebiz_prod_80
}
}
}
- I am using set to append the True-Client-IP variable with an %1 due to route-domain requirements
The iRule seems to work fine but I can see a lot of error messages in /var/log/ltm:
May 26 17:58:26 err tmm2[10930]: 01220001:3: TCL error: /DMZ_700/irule_-prod-80-EMD - bad IP address format (line 3) invoked from within "whereis $True_Client_IP country"
May 26 17:58:28 err tmm3[10930]: 01220001:3: TCL error: /DMZ_700/irule_-prod-80-EMD - bad IP address format (line 3) invoked from within "whereis $True_Client_IP country"
May 26 17:58:32 err tmm1[10929]: 01220001:3: TCL error: /DMZ_700/irule_-prod-80-EMD - bad IP address format (line 3) invoked from within "whereis $True_Client_IP country"
May 26 17:58:43 err tmm3[10930]: 01220001:3: TCL error: /DMZ_700/irule_-prod-80-EMD - bad IP address format (line 3) invoked from within "whereis $True_Client_IP country"
May 26 17:58:46 err tmm[10929]: 01220001:3: TCL error: /DMZ_700/irule_-prod-80-EMD - bad IP address format (line 3) invoked from within "whereis $True_Client_IP country"
May 26 17:58:48 err tmm1[10929]: 01220001:3: TCL error: /DMZ_700/irule_-prod-80-EMD - bad IP address format (line 3) invoked from within "whereis $True_Client_IP country"
May 26 17:58:52 err tmm3[10930]: 01220001:3: TCL error: /DMZ_700/irule_-prod-80-EMD - bad IP address format (line 3) invoked from within "whereis $True_Client_IP country"