基于OpenResty ,MaxMind GeoIP数据库和从bgp.he.net生成的ASN数据库,因为没有经纬度的需求所以没有显示。下文有源代码的链接,如果需要可以自行修改加上经纬度或者将输出变为JSON等。
需要ngx_http_geoip_module, echo-nginx-module, lua-nginx-module,安装libgeoip,并将maxmind的旧版geoip数据库放在/usr/share/GeoIP
通过bgp.he.net生成ASN数据库
This service is based on OpenResty, MaxMind GeoIP database and ASN database generated by bgp.he.net. There’s no lat/lng since I don’t need it. Source code is attached below. You can modify it to display lat/lng or output JSON.
nginx with ngx_http_geoip_module, echo-nginx-module, lua-nginx-module is required; libgeoip needs to be installed and geoip database should be placed under
Generate ASN database from bgp.he.net
使用方法
查询当前IP地理位置$ curl https://ipip.tk/查询当前IP
x.x.x.x
Country, City
ASN number
$ curl https://ipip.tk/ip查询指定IP的地理位置
x.x.x.x
$ curl https://ipip.tk/74.125.203.199查询域名的地理位置
74.125.203.199
United States, Mountain View
AS15169 Google Inc.
$ curl https://ipip.tk/www.google.com.hk查询域名的IP
74.125.203.199
United States, Mountain View
AS15169 Google Inc.
$ curl https://ipip.tk/www.google.com.hk/ip查询域名的IP和CNAME(如果存在)
74.125.203.199
$ curl https://ipip.tm/www.google.com.hk/dns
www-wide.l.google.com 74.125.203.199
源代码
在这里https://gist.github.com/fffonion/44e5fb59e2a8f0efba5c1965c6043584需要ngx_http_geoip_module, echo-nginx-module, lua-nginx-module,安装libgeoip,并将maxmind的旧版geoip数据库放在/usr/share/GeoIP
通过bgp.he.net生成ASN数据库
This service is based on OpenResty, MaxMind GeoIP database and ASN database generated by bgp.he.net. There’s no lat/lng since I don’t need it. Source code is attached below. You can modify it to display lat/lng or output JSON.
Usage
Query current IP geo location$ curl https://ipip.tk/Query current IP
x.x.x.x
Country, City
ASN number
$ curl https://ipip.tk/ipQuery given IP geo location
x.x.x.x
$ curl https://ipip.tk/74.125.203.199Query given domain name geo location
74.125.203.199
United States, Mountain View
AS15169 Google Inc.
$ curl https://ipip.tk/www.google.com.hkQuery given domain name IP
74.125.203.199
United States, Mountain View
AS15169 Google Inc.
$ curl https://ipip.tk/www.google.com.hk/ipQuery given domain name IP and CNAME (if exists)
74.125.203.199
$ curl https://ipip.tm/www.google.com.hk/dns
www-wide.l.google.com 74.125.203.199
Installation
Source code can be viewed here: https://gist.github.com/fffonion/44e5fb59e2a8f0efba5c1965c6043584nginx with ngx_http_geoip_module, echo-nginx-module, lua-nginx-module is required; libgeoip needs to be installed and geoip database should be placed under
/usr/share/GeoIP
.Generate ASN database from bgp.he.net
No comments:
Post a Comment