我有一个IP地址列表,其中许多地址可能来自大学网络。如何最好地找出此列表中包含哪些大学?
我有一个IP地址列表,其中许多地址可能来自大学网络。如何最好地找出此列表中包含哪些大学?
$ curl ipinfo.io/128.32.0.1
{
"ip": "128.32.0.1",
"hostname": "No Hostname",
"city": "Berkeley",
"region": "California",
"country": "US",
"loc": "37.8668,-122.2536",
"org": "AS25 University of California at Berkeley",
"postal": "94720"
}
$ curl ipinfo.io/128.32.0.1/org
AS25 University of California at Berkeley
您可以通过将IP地址放入文件中并运行以下命令来批量查找它们:
$ cat ips.txt | xargs -I% curl -s http://ipinfo.io/%/org | paste ips.txt -
128.32.0.1 AS25 University of California at Berkeley
128.62.76.244 AS18 University of Texas at Austin
24.32.142.2 AS7018 AT&T Services, Inc.
171.64.84.194 AS32 Stanford University
18.9.44.47 AS3 Massachusetts Institute of Technology
67.188.232.130 AS7922 Comcast Cable Communications, Inc.
你可以在http://ipinfo.io/developers上了解有关API的更多详细信息。
SELECT * FROM `isp_universities`
WHERE INET_ATON('192.16.181.4')
BETWEEN from_dec AND to_dec
获得:
192.16.181.0 to 192.16.181.255
Massachusetts Institute of Technology
http://www.mit.edu/
请看这里, 我已经将数据库推送到Bitbucket上了。