简体   繁体   English

IP2获取用户校园的位置

[英]IP2Location to get user's campus

I'm writing a web page that will detect which college campus a user is accessing the site from. 我正在写一个网页,它将检测用户正在从哪个大学校园访问该网站。 I have a list of which IP ranges go with which campuses. 我列出了哪些IP范围与哪些校园一起使用。 My question is whether it would be better to detect the user's campus from their IP, using this list, or from their hostname, or both. 我的问题是,从用户的IP(使用此列表)还是从用户的主机名(或同时从两者)检测用户的园区是否更好?

My concern with using IP ranges is that these may change, and my list (found online) may already be out of date. 我对使用IP范围的担心是这些范围可能会更改,并且我的列表(在线找到)可能已经过时。 My concern with using hostnames is that I don't know whether all campus computers will have the hostname of the campus. 我对使用主机名的担心是,我不知道所有校园计算机是否都具有校园的主机名。 If neither of these methods is sufficient, maybe I should use both? 如果这些方法都不足够,也许我应该同时使用?

I think the most logical answer would be to use hostnames first, since they're less likely to change or be expanded. 我认为最合乎逻辑的答案是首先使用主机名,因为它们不太可能更改或扩展。 It might also give you some durability against things like a mass transition to IPv6, which is bound to happen eventually. 它还可能使您对诸如向IPv6的大规模过渡这样的事情具有一定的持久性,而这最终必将发生。 But I would never trust one source to always provide the info you need, so I'd say you could use the IP ranges as a backup. 但是我永远不会相信任何来源总是提供您所需的信息,因此我想您可以将IP范围用作备份。

You could get different answers to this, each with its own merits and downfalls, but I think lots of people would say to check both in some order. 您可能会得到不同的答案,每个答案都有其优点和缺点,但是我认为很多人会说要按一定顺序进行检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM