Menu Title

BIG-IP LTM url redirection based on Geolocation

There is no necessity to rewrite about downloading and installing Geo-location database as we have a friendly article written in F5 repository here. You can follow as guided in the article and you should be able to successfully complete setting up Geo-location in your F5 box.


[admin@nlb01:Active:In Sync] ~ # cd /shared/tmp

[admin@nlb01:Active:In Sync] tmp # md5sum -c OK

[admin@nlb01:Active:In Sync] tmp # unzip

inflating: geoip-data-Region2-1.0.1-20160303.221.0.i686.rpm
inflating: geoip-data-ISP-1.0.1-20160303.221.0.i686.rpm
inflating: geoip-data-Org-1.0.1-20160303.221.0.i686.rpm
inflating: geoip-data-v6-1.0.1-20160303.221.0.i686.rpm
inflating: README.txt

[admin@nlb01:Active:In Sync] tmp # geoip_update_data -f geoip-data-Region2-1.0.1-20160303.221.0.i686.rpm
[admin@nlb01:Active:In Sync] tmp # geoip_update_data -f geoip-data-ISP-1.0.1-20160303.221.0.i686.rpm
[admin@nlb01:Active:In Sync] tmp # geoip_update_data -f geoip-data-Org-1.0.1-20160303.221.0.i686.rpm
[admin@nlb01:Active:In Sync] tmp # geoip_update_data -f geoip-data-v6-1.0.1-20160303.221.0.i686.rpm

Now in iRule, redirect your visitors of main website to different geographical edition of website based on their IP address. Geo-location database has IP address to Country Code mapping, which is actually an ISO 2 digit country code (refer for any specific country code).

if {[HTTP::path] eq “/” }
set client_ip [IP::client_addr]
set client_country [whereis $client_ip country]
if { $client_ip ne “” } {
switch [string toupper [whereis $client_ip country]] {
“OM” { HTTP::redirect “” }
“KW” { HTTP::redirect “” }
“AE” { HTTP::redirect “” }
“QA” { HTTP::redirect “” }
default { HTTP::redirect “” }

Its very important that you use absolute URI in HTTP::redirect

Helpful Geolocation CLI commands:

# geoip_lookup query the IP geolocation database for the location of a specific IP address
# geoip_lookup -f /shared/GeoIP/F5GeoIPOrg.dat query a specific IP geolocation database file using -f command
# ls -ltr /shared/GeoIP/To findout the release date of the IP geolocation database file that is stored in your F5 appliance



You may also like...

Thank you for visiting us. To continue receiving updates, please Subscribe to our Social Media Channels.