DataScript: avi.utils.get_geo_from_ip

Note: This function is supported in Avi Vantage release 18.1.5+.


Function avi.utils.get_geo_from_ip ( ip_string )
Description For a given IP address, returns the 2-character country code from the geolocation database
Events All HTTP events
Parameter ip_string is the IP address for which geo-database information (country code) is queried.

Note: The database used for this function is equivalent to the default one maintained on the Avi Controller. It cannot be overridden or augmented with IP groups, as mentioned in the Geolocation Database article.
Returns ISO 3166-1 alpha-2 country code associated with that IP.
Nil if IPv6, internal, or invalid address is provided.

   c_code = avi.utils.get_geo_from_ip( avi.vs.client_ip() )
   if (c_code == "CN" or c_code == "NG") then
      avi.http.add_header("Country", c_code)