Identifying country by IP address
I think what you're looking for is an IP Geolocation database or service provider. There are many out there and some are free (get what you pay for).
Although I haven't used this service before, it claims to be in real-time. https://kickfire.com/kf-api
Here's another IP geo location API from Abstract API - https://www.abstractapi.com/ip-geolocation-api
But just do a google search on IP geo and you'll get more results than you need.
No you can't - IP addresses get reallocated and reassigned from time to time, so the mapping of IP to location will also change over time.
If you want to find out the location that an IP address currently maps to you can either download a geolocation database, such as GeoLite from MaxMind, or use an API like http://ipinfo.io (my own service) which will also give you additional details:
$ curl ipinfo.io/8.8.8.8
{
"ip": "8.8.8.8",
"hostname": "google-public-dns-a.google.com",
"loc": "37.385999999999996,-122.0838",
"org": "AS15169 Google Inc.",
"city": "Mountain View",
"region": "California",
"country": "US",
"phone": 650
}