If you ever go to http://www.hostip.info/, you will find a Community Geotarget IP Project. The great thing about it is that it is free to use. :)
Now, this is just a snippet of code to begin working in the world of GeoIPs. There's a lot more info to be gotten, and if you go to http://www.hostip.info/use.html, you will find many different ways of calling the information that you need.
Just my 2¢. Thought I'd share.