如何在不使用 API 的情况下查找 IP 地址的位置?
更多的是一个理论问题。是的,我知道这些类型的问题在这里是不受欢迎的。但是假设像 MaxMind GeoIP 这样的 API 不存在,并且您想要构建一个将 IP 地址转换为其所在城市的服务。您会怎么做?你会如何解决这个问题?
More of a theoretical question. Yes, I know those types of questions are frowned upon here. But suppose APIs like MaxMind GeoIP's didn't exist, and you wanted to build a service that translated IP addresses to the city it's in. What would you do? How would you go about solving that problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
作为示例,让我们看一下 stackoverflow.com (64.34.119.12)
whois 向我们显示他们可能位于 NY, NY。
反向 DNS(PTR 记录)在这里没有帮助。然而,许多 ISP 确实有区域特定的反向 DNS 条目,可以帮助完成此过程(特别是对于动态分配的主机)。举个例子:
这个主机显然是通过它的 PTR 记录来识别和定位的:位于加利福尼亚州圣地亚哥的时代华纳(Road Runner)缓存 DNS 服务器。
现在,回到 stackoverflow.com 定位过程:
traceroute 输出证实了我们的怀疑,即 stackoverflow.com 托管在纽约州纽约市。
这是无需 API 即可解决地理定位问题的一种方法。
As an example, lets look at stackoverflow.com (64.34.119.12)
whois shows us that they're probably in NY, NY.
Reverse DNS (PTR record) doesn't help here. However, a lot of ISPs do have region specific reverse DNS entries that can help with this process (especially for dynamically assigned hosts). As an example:
This host is obviously identified and located by it's PTR record: a Time Warner (Road Runner) caching DNS server in San Diego, CA.
Now, back to the stackoverflow.com locating process:
The traceroute output confirms our suspicion that stackoverflow.com is hosted in NY, NY.
That's one way to tackle geolocation without an API.
我真的在这里猜测,但这可能有效。
IP 范围由 IANA 分配给区域提供商。他们有五个。反过来,每个区域提供商将 IP 范围分配给最终用户和互联网服务提供商。
如果您可以从区域提供商及其 ISP 客户处获取/购买信息,那么您就可以开展业务。
Im really guessing here but this may work.
IP ranges are assigned by IANA to regional providers. There are five of them. In turn each regional provider assign IP ranges to end users and internet service provides.
If you can get/buy the information from the regional providers and their ISP clients you are in business.