Reading the wikipedia entry for geo targeting, one would think this a near-impossible task:
The automated discovery of user city-level information based on IP addresses by trace routes, pings, and a combination of other tools and methods is far more advanced. It is dependent on the pre-analysis of the entire IP address space. There are more than 4 billion possible IP addresses, and detailed analysis of each of them is a Herculean task, especially in light of the fact that IP addresses are constantly being assigned, allocated, reallocated, moved and changed due to routers being moved, enterprises being assigned IP addresses or moving, and networks being built or changed. In order to keep up with these changes, complex algorithms, bandwidth measurement and mapping technology, and finely tuned delivery mechanisms are necessary. Once all of the IP space is analyzed, each address must be periodically updated to reflect changes in the IP address information. This process is analogous to Internet search engine spidering in its enormity, yet requires far deeper layers of intelligence to keep the information about the constantly changing 4 billion-plus IP addresses current.
Yes, sorting out the potential four billion IP addresses (only about half are actually assigned) can be a “Herculean task,” especially if one is trying to achieve province and metro area granularity. But the good news is if you are geo targeting by country only, regularly maintained databases are 99 percent accurate.
Here is a recent example: a US-based company had a strong presence in a South American country with an application that is virtually required by way of new tax laws going into effect January 2009. With the help of a translator, I wrote two sites: one in Portuguese featuring the existing product and another site in English primarily for the North American market. Directing visitors to the site automatically is a rather simple task, and is available in java, perl, php and asp constructions. One reliable provider delivers a free download of their IP-to-country database that is updated every 24 Hours (look for “Download the Entire Database” on the right-hand side). They also have a page of free scripts that will help your Web developer redirect visitors to a page or site you select by country of inquiry.
Implementation is simple, and if your IT manager recoils at “free” databases, a longtime provider is IP2Location, which provides its database for US$49 and includes 11 months of monthly upgrades.