Forum Discussion

Demeter_Luo's avatar
Demeter_Luo
Icon for Nimbostratus rankNimbostratus
Nov 08, 2016

Geo-location can be LTM moudle outbound irules use?

Hi Everyone

 

I have a LTM combo GTM divice. I hope use Geolocation IP databse in Ltm Outbound iRules. But I test may not be able to use.

 

Thanks

 

D.Luo

 

  • Here is an IRULE that uses the GTM and Google Maps

    when HTTP_REQUEST {
        set ip [URI::query [HTTP::uri] ip]
        set response "\n  \n    IP Address Geolocation Data Search\n  \n  \n"
    
        if { ![catch {IP::addr $ip mask 255.255.255.255} ] } {
            set geo_properties { country state city zip isp org }
    
            append response "    
          IP Address Geolocation Data Search
          
            
              IP
              $ip
            \n"
    
            foreach property $geo_properties {
                set result [whereis $ip $property]
    
                if { $result ne "" } {
                    append response "        
              [string toupper $property]
              [string toupper $result]
            \n"
                }
            }
    
            append response "      \n"
    
            set latitude [whereis $ip latitude]
            set longitude [whereis $ip longitude]
    
            if { ($latitude != 0) && ($longitude != 0) } {
                append response "      \n      \n      \n      lat: $latitude, long: $longitude\n"
            } else {
                append response "      \n      \n"
            }
    
            append response "    "
        } else {
            append response {    
          IP Address Geolocation Data Search
          
            IP: 
            
          
        }
        } 
    
        append response "\n  \n"
    
        HTTP::respond 200 content $response
    }
    

    I hope this helps, The Bhattman