Are you looking for zip code accuracy or just country accuracy? or something in between?
If all you want is what country the IP is from then go to http://www.ip2location.com/ and look through the forums. You can find out how to do it yourself.
If you need really fine granularity you will need a for pay service.
The Maxmind GeoIP database is what most people are using. It's quite accurate, has good libraries for many languages, but it's proprietary and costs money.
(Starting an open source competitor is on my list of fun projects to do)
If all you want is what country the IP is from then go to http://www.ip2location.com/ and look through the forums. You can find out how to do it yourself.
If you need really fine granularity you will need a for pay service.