Is there a way to figure out the country name just by looking at an IP address? I mean, do countries have specific ranges of IP addresses? For example, Australia can have IP addresses only in the range of 123.45.56.89 - 231.54.65.98
(just an example)
相关问题
- IPAddress.[Try]Parse parses 192.168 to 192.0.0.168
- Doing ARP and Inverse ARP on Linux 2.6.21 (glibc 2
- How to transform IP addresses into geolocation in
- Location not updating on server when app enters st
- Mapbox 'setMyLocationEnabled' doesn't
相关文章
- How to resolve hostname to an ip address in node j
- PostgreSQL field data type for IPv4 addresses
- Parsing IP Address to string doesn't work for
- How to find that an IP address is a LAN IP or WAN
- Direct IP call android
- Automate ftp upload to ip
- Implementing Triangulation in android [closed]
- Retrieve IP Address of the Default Printer Driver
You could use ipdata.co to perform the lookup
Ipdata has 10 endpoints globally each able to handle >10,000 requests per second!
Gives
I agree with above answers, the best way to get country from ip address is Maxmind.
If you want to write code in java, you might want to use i.e. geoip-api-1.2.10.jar and geoIP dat files (GeoIPCity.dat), which can be found via google.
Following code may be useful for you to get almost all information related to location, I am also using the same code.
It's not that easy. IP adresses are not assigned to countries as such, but to companies and organizations.
But maybe this can help you out: http://www.maxmind.com/app/geolitecountry
Yes, you can download the IP address ranges by country from https://lite.ip2location.com/ip-address-ranges-by-country
You can see that each country has multiple ranges and changes frequently.
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
But just do a google search on IP geo and you'll get more results than you need.
Amazon's CloudFront content delivery network can now be configured to pass this information through as a header. Given Amazon's size (they're big and stable, not going anywhere) and this is configuration over code (no third-party API to learn or code to maintain), all around believe this to be the best option.
If you do not use AWS CloudFront, I'd look into seeing if your CDN has a similar header option that can be turned on. Usually the large providers are quick to push for feature parity. And if you are not using a CDN, you could put CloudFront in front of your infrastructure and simply set the origin to resolve to whatever you are currently using.
Additionally, it also makes sense to resolve this at the CDN level. Your CDN is already having to figure out geo location to route the user to the nearest content node, might as well pass this information along and not figure it out twice through a third party API (this becomes chokepoint for your app, waiting for a geo location lookup to resolve). No need to do this work twice (and the second time, arguably less resilient [e.g., 3rd party geo lookup]).
https://aws.amazon.com/blogs/aws/enhanced-cloudfront-customization/