F5Hopper_28651
Aug 15, 2016Nimbostratus
Geolocation irule for states
so I have read many irules on the dev site, creating mine.
when HTTP_REQUEST {
if { ([string tolower [HTTP::uri]] starts_with "/testingpage") } {
Parse the client IP from the CDN header
set client_ip [HTTP::header value "Client-IP"]
if { $client_ip eq "" }{
The header was empty/did not exist, so use the actual client IP
set client_ip [IP::client_addr]
}
set state [string tolower [whereis $client_ip abbrev]]
switch $state {
"NJ" -
"ID" {
HTTP::respond 200 content "Your IP IS from NJ or ID"
}
default {
Redirect all others
set state [whereis $client_ip abbrev]
HTTP::respond 200 content "Your IP IS NOT NJ or ID you is $state"
}
}
}
}
my issues is that I get no return state result. just says "Your IP IS NOT NJ or ID you is " and nothing after that...
when i check the local CLI I get.
[admin@BIG-IP-VE-LAX01-POC:Active:Standalone] ~ geoip_lookup 148.74.227.1
Will attempt to lookup ip '148.74.227.1'
No database specified.
opening database in /usr/share/GeoIP/v2/F5GeoIP.dat
size of geoip database = 32235638, segments = 12797693, version = Copyright (c) F5 Networks Inc, All Rights Reserved GEOIP2 v1, 20160303
geoip_seek = 00e102c4
geoip record ip = 148.74.227.1
country_code = US
country_name = United States
region_name = New Jersey
continent_code = NA
any ideas whats going on?