Location detecting techniques for IP addresses

前端 未结 9 1217
甜味超标
甜味超标 2020-11-28 12:22

What are the location detecting techniques for IP addresses?
I know to look at the
$_SERVER[\'HTTP_ACCEPT_LANGUAGE\'] (not accurate but mostly useful to

9条回答
  •  余生分开走
    2020-11-28 12:41

    You can't do this without a database that maps IP addresses to cities/countries/providers. There are commercial offerings such as ip2location that you could use. AFAIK there is no free alternative though, as maintaining such a IP database is quite a lot of work. Free alternative: GeoIP2

    Update: There are several things that allow you to create such a db, if you invest enough time:

    1. Use the databases provided by regional and local registries to find an IP's owner.
    2. Many ISPs use a naming schema that allows you to locate the user. Sometimes you can even read the city name in plain text if you do a reverse-DNS lookup. Sometimes it is more cryptic. For example I currently have p5dcf6c4a.dip.t-dialin.net , and I have no idea that the naming scheme is..
    3. Use a traceroute. If you can't identify the location of a user, you can still find out the location of its uplink

提交回复
热议问题