IP信息与地理位置查询方法
理解 IP 地址以及其相关的地理位置信息对于网络管理、地理定位、信息安全等多个方面都极其重要。以下是获取当前请求者的公网 IP、查询指定 IP 地址信息、地理位置反查和地点查询的方法。
查询方法
一、基本IP信息查询
获取当前请求者的公网IP:
- 使用命令:
curl https://ifconfig.me/
- 或使用命令:
curl https://httpbin.org/ip
- 或使用命令:
curl ipinfo.io
- 或使用命令:
curl ip.fm
- 使用命令:
获取当前请求者的公网IP及相应详细的地理位置信息:
- 使用命令:
curl https://myip.ipip.net/
- 或使用命令:
curl ip.sb
- 或使用命令:
curl ipip.sh
- 或访问:
curl http://ip111.cn
: ip111.cn 全方位查询您的 IP 地址
- 使用命令:
二、指定IP信息查询
查询指定IP地址所在的城市信息:
- 使用命令:
curl https://geoip.samagra.io/city/128.101.101.101
- 使用命令:
三、地理位置反查
通过经纬度查询地理信息:
- 使用命令:
curl https://geoip.samagra.io/georev?lat=28.7041&lon=77.1025
- 使用命令:
四、地点查询
查询指定地区(例如Lucknow)的地理中心点:
- 使用命令:
curl https://geoip.samagra.io/location/DISTRICT/centroid?query=lucknow
- 使用命令:
参考资源
- Geoquery.in:提供 IP 地理位置查询服务的 GitHub 项目。