Find the country by ip address
You want to find which the country associates with a certain ip address ? Check out this link:
But if you want to have a service that looks for a country of any ip address (like the one in above link), you many need a database of ip country codes. There are a lot of them available online and you can download for free. Then do the rest part with your code.