Checking IP Against Geo-Protection Database

Document created by Nathan Johnson Employee on Jan 26, 2017Last modified by Nathan Johnson Employee on Jul 11, 2017
Version 1Show Document
  • View in full screen mode


This code takes in a user input for an IPv4 address and searches for it in the Geo-Protection Database, returning the country of origin.



This python script allows a user to quickly search the IpToCountry.csv file to find the country of origin for a given IPv4 address.  It does all the necessary IP to decimal conversions automatically and uses that to iterate through the CSV.


For more information on how the  IpToCountry.csv file works, please see SK94364



Download the Python scripts below and place them in the same directory.  (Note: Script was written in Python 2.7)

Copy the IpToCountry.csv file from a security gateway, located in the $FWDIR/tmp/geo_location_tmp/updates/ directory, to the same directory as the files above


Input the IPv4 address you'd like to check


Code Version

Code version 1.0.0


Tested on version

R77.30 IpToCountry.csv file


NOTICE: By using this sample code you agree to terms and conditions in this Terms and Conditions


1 person found this helpful