Does anyone know any simple way to retrieve the country from a given IP Address, preferably in ISO_3166-1 format?
There are two approaches: using an Internet service and using some kind of local list (perhaps wrapped in a library). What you want will depend on what you are building.
For services:
For lists:
You could roll your own by downloading the lists from the RIRs:
ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-latest
The format is documented in this README