139 lines
2.8 KiB
Markdown
139 lines
2.8 KiB
Markdown
# geoipweb
|
|
|
|
Get informations about an IP address.
|
|
|
|
## Description
|
|
|
|
A simple service for getting informations about an IP address.
|
|
|
|
This is the code that powers [iplookup.fr](https://iplookup.fr)
|
|
|
|
## Getting Started
|
|
|
|
### API usage examples
|
|
|
|
Getting your IP address:
|
|
```
|
|
$ curl iplookup.fr
|
|
82.65.42.142
|
|
```
|
|
|
|
Check if your port 443 is publicly open:
|
|
```
|
|
$ curl iplookup.fr/443
|
|
Port 443 is closed
|
|
```
|
|
|
|
Getting 9.9.9.9 country:
|
|
```
|
|
$ curl iplookup.fr/9.9.9.9/country
|
|
United States
|
|
```
|
|
|
|
Getting 9.9.9.9 hostname:
|
|
```
|
|
$ curl iplookup.fr/9.9.9.9/hostname
|
|
dns9.quad9.net
|
|
```
|
|
|
|
Find if 1.1.1.1's port 443 is open:
|
|
```
|
|
$ curl iplookup.fr/1.1.1.1/443
|
|
Port 443 is open
|
|
```
|
|
|
|
Also work with a host:
|
|
```
|
|
$ curl iplookup.fr/rznet.fr/80
|
|
Port 80 is open
|
|
```
|
|
|
|
Getting all 9.9.9.9 informations, with pretty yaml format:
|
|
```
|
|
$ curl iplookup.fr/9.9.9.9
|
|
asn: AS19281
|
|
city: Berkeley
|
|
country: United States
|
|
country_code: US
|
|
hostname: dns9.quad9.net
|
|
hostnames:
|
|
- dns9.quad9.net
|
|
ip: 9.9.9.9
|
|
ip_address: 9.9.9.9
|
|
isp: QUAD9-AS-1
|
|
latitude: 37.8767
|
|
longitude: -122.2676
|
|
```
|
|
|
|
Getting all your own infomations, in yaml then in json:
|
|
```
|
|
$ curl iplookup.fr/all
|
|
asn: AS12322
|
|
city: null
|
|
country: France
|
|
country_code: FR
|
|
hostname: 82-65-42-142.subs.proxad.net
|
|
hostnames:
|
|
- 82-65-42-142.subs.proxad.net
|
|
ip: 82.65.42.142
|
|
ip_address: 82.65.42.142
|
|
isp: Free SAS
|
|
latitude: 48.8582
|
|
longitude: 2.3387
|
|
|
|
$ curl iplookup.fr/json
|
|
{"asn":"AS12322","city":null,"country":"France","country_code":"FR","hostname":"82-65-42-142.subs.proxad.net","hostnames":["82-65-42-142.subs.proxad.net"],"ip":"82.65.42.142","ip_address":"82.65.42.142","isp":"Free SAS","latitude":48.8582,"longitude":2.3387}
|
|
```
|
|
|
|
And you can find more examples in the website [iplookup.fr](https://iplookup.fr)
|
|
|
|
### Dependencies
|
|
|
|
ipinfo require local geoip databases (.mmdb), located by default in /var/lib/GeoIP.
|
|
|
|
I recommend using [geoipupdate](https://github.com/maxmind/geoipupdate) with a free key.
|
|
|
|
#### Docker
|
|
|
|
- docker
|
|
- docker-compose
|
|
- geoipupdate
|
|
|
|
#### Source
|
|
|
|
- python3
|
|
- geoipupdate
|
|
- geoip2>=4.5.0
|
|
- Flask>=2.0.3
|
|
- netaddr>=0.8.0
|
|
- pyyaml>=6.0
|
|
|
|
### Installing
|
|
|
|
#### Docker
|
|
```
|
|
git clone https://git.rznet.fr/razian/geoipweb.git
|
|
cd geoipweb-py
|
|
vim docker-compose.yml
|
|
# edit port and geoip volume
|
|
# you can also change the site title with GEOIPNAME env var
|
|
docker-compose up -d
|
|
```
|
|
|
|
#### Source
|
|
```
|
|
git clone https://git.rznet.fr/razian/geoipweb.git
|
|
cd geoipweb-py
|
|
pip install --upgrade -r requirements.txt
|
|
python -m flask run --host=0.0.0.0 --port=8080
|
|
```
|
|
|
|
## Acknowledgments
|
|
|
|
* [ifconfig.io](https://github.com/georgyo/ifconfig.io)
|
|
* [ifconfig.co](https://github.com/mpolden/echoip)
|
|
* [geoipupdate](https://github.com/maxmind/geoipupdate)
|
|
|
|
## License
|
|
|
|
This project is licensed under the MIT License. See the [LICENSE](https://git.rznet.fr/tchivert/geoipweb/src/branch/main/LICENSE) file for more information. |