What is the most applicable solution to detect which country an ip belongs to?
Asked Answered
U

4

1

Someone recommended cdn,

And is it accurate in judging where the IP address belong to?

How is it done?

Is there a better solution?

Ultimo answered 20/9, 2009 at 16:53 Comment(2)
In US, or CDN dollars? Ha ha! I kill me.Devaney
Not sure what you mean by "hardware" cdn. Are you referring to the cost of contracting with a commercial cdn like akamai for the distribution of your static content?Powder
E
3

Try hitting the pidgets geoip service (it uses the maxmind database)

http://geoip.pidgets.com

Engender answered 20/9, 2009 at 17:20 Comment(3)
I want to programatically do that.Ultimo
Instructions on how to do that programatically are included on that page. The actual response is an xml document that is easy to parse (you can also get a json document if you prefer).Beautifully
Looks good, but it says: "This isn't meant to be a production service. This is just a handy little service I set up for use by students at Hack Days for temporary small projects."Sylviesylvite
B
1

There no fixed rules that can tell you which IP belongs to which country. It depends on which company owns the IP range at a given time and therefore can change as the ownership changes. You therefore either need to keep up an up to date database about which company owns which IP range yourself or you rent access to such a database.

Broglie answered 20/9, 2009 at 17:31 Comment(4)
You mean which country owns which IP range is a dynamic thing?Ultimo
It doesn't change on a day to day basis but it can change from year to year. Just imagine a new ISP opening up. Of course that ISP needs IP ranges and the database therefore needs updating. The same goes for an ISP needing more IPs than that ISP previously had.Broglie
I think it assignment within a specific country is change-able,but not for internationalUltimo
Below the international level you have five different regional NIC's such as ripe.net The regulation doesn't happen at a country level.Broglie
P
0

Not sure what the link of a CDN and ip/geo lookup is. However, if you use a cdn to deliver content, they will provide reporting on where the users are coming from. See my blog post for more details on CDNs.

Regarding looking up a user's country from their IP. There are a couple ways to do this. It is fairly acurate. I'd certainly say it is accurate "enough." If you simply want to lookup the country of a few IPs. Go to a site like dnsstuff.com and they have online tools for doing that. If you want to programatically do this, use a service like Maxmind or digital envoy. Maxmind is the much cheaper option.

Powder answered 20/9, 2009 at 17:16 Comment(1)
Is it possible to implement by self?Ultimo
B
0

You can do a GET request to this URL: https://api.teletext.io/api/v1/geo-ip and it will respond with some country information in JSON format.

If you want to implement it yourself: I've set this up by using AWS Cloudfront, Cloudfront adds a header (Cloudfront-Viewer-Country) to your request before it forwards it to the origin server that you can use. Make sure to whitelist the header in your Cloudfront distribution.

Benia answered 4/11, 2015 at 14:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.