This project is read-only.

There are many website out there in the internet that displays users country based on the IP address.

I tried to find a service which is free of cost and gives us accurate results based on the IP but i didnt find any. So i thought of writing my own api.

A Brief About American Registry for Internet Numbers (ARIN):
The American Registry for Internet Numbers (ARIN) is the Regional Internet Registry (RIR) for Canada, many Caribbean and North Atlantic islands, and the United States. ARIN manages the distribution of Internet number resources, including IPv4 and IPv6 address space and AS numbers. ARIN opened its doors for business on December 22, 1997[1] after incorporating on April 18, 1997.[2] ARIN is a nonprofit corporation with headquarters in Chantilly, Virginia, USA.[3][4]

What does they do:

IPv4 address allocation and assignment
IPv6 address allocation and assignment
AS number assignment
Directory services including:
Registration transaction information (WHOIS)
Routing information (Internet Routing Registry)
DNS (Reverse)
Note: This was copied from Wikipedia

There are few other orgnizations(total of 5) accross the globe similar to ARNIC. They perform similar kind of job.

Raw data provided by Arnic related to IP address allocation
Aric provides few files that provides raw data about the IP allocation in different countries.

Root Solution File

MY project Implementation
1.The core project for this is GeneratefilesLibrary.csproj. it contains 2 class files
--GenerateFiles.cs : In this class file i am trying to read the raw data present in all the 5 ftp sites mentioned above and i am writing required data to like Europe.txt,North-America.txt,Asia.txt,Africa.txt,latinAmerica.txt. These files contains startIPAddress and country Name.

Later i am having a file \\GetCountryFromIP\\IpData\\IPCountry.txt which will contain data from all the above mentioned files. here i am trying to remove some unnecessary data from all the above 5 files.

How do we analyze raw data:

Here AU refers Australia and JP refers japan.
If we see 1st one the IP address is the address that was allocated to AU and is the starting one to JP. So all the IP address that were in between comes under AU. Like it comes under AU and it comes under JP. Again starting from to some other IP falls under AU.

2. Initially i am having a console application(GenerateFiles.csproj) this will call GenerateFiles class and generates required files for processing.

Note this console app can be executed only once per day to get updated values from server(ARIN) , we can write a windows scheduler to execute this console app everyday and collect raw data

3.Now we are having required files for processing. GetCountryNames.cs file contains the logic to proccess these files and get exact 2 letter country code for a given IP address.

4. Now i am having a servcie(asmx service) which is going to call a method in getCountryNames.cs and output the country name(2 letter country code) to the end user.


Last edited Jun 7, 2013 at 6:37 PM by paryasomayajulu, version 2