To lookup the country code of a particular IP address, in this example, you need to retrieve the TXT record (TXT, not A record!) of This will return you the two-letter ISO country code of the IP address requested.

So to summarise there are two steps involved:

  1. Reverse the order of the IP address. Example: becomes
  2. Lookup the DNS TXT record of "reversed IP address" + "". Example:
It is important your application only and exclusively requests the TXT record and nothing else. Requesting other records types (A, MX, CNAME, etc.) is pointless and wastes resources. Users or applications not following this simple point will unfortunately be blocked.