-
Notifications
You must be signed in to change notification settings - Fork 31
/
README
121 lines (82 loc) · 3.91 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# IP2Location C Library
IP2Location is a C library that enables the user to find the country, region or state, district, city, latitude and longitude, ZIP/Postal code, time zone, Internet Service Provider (ISP) or company name, domain name, net speed, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC) and carrier brand, elevation, usage type, address type, IAB category and ASN by IP address or hostname originates from. The library reads the geo location information
from **IP2Location BIN data** file.
In addition to the C Library, the build process will also create an executable called "**ip2location**" that allows you to directly perform IP geolocation lookups. Please refer to the ip2location CLI documentation for more information.
Supported IPv4 and IPv6 address.
For more details, please visit:
[https://www.ip2location.com/developers/c](https://www.ip2location.com/developers/c)
# Installation
### Unix/Linux
autoreconf -i -v --force
./configure
make
make install
cd data
perl ip-country.pl
### Debian
```
curl -LO https://github.com/chrislim2888/IP2Location-C-Library/releases/download/8.6.1/ip2location-8.6.1.deb
sudo dpkg -i ip2location-8.6.1.deb
```
### Ubuntu
```
sudo add-apt-repository ppa:ip2location/ip2location
sudo apt update
sudo apt install ip2location
```
### Windows
Execute "vcvarsall.bat". (This file is part of Microsoft Visual C, not ip2location code)
nmake -f Makefile.win
cd data
perl ip-country.pl
### MacOS
autoreconf -i -v --force
export CFLAGS=-I/usr/include/malloc
./configure
make
make install
cd data
perl ip-country.pl
# Testing
cd test
test-IP2Location
# Sample BIN Databases
* Download free IP2Location LITE databases at [https://lite.ip2location.com](https://lite.ip2location.com)
* Download IP2Location sample databases at [https://www.ip2location.com/developers](https://www.ip2location.com/developers)
# IPv4 BIN vs IPv6 BIN
* Use the IPv4 BIN file if you just need to query IPv4 addresses.
* Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.
# NOTES
If you encountered **error while loading shared libraries** in linux platform, that could be due to the shared library was saved into **usr/local/lib** that might not be the default library path. You can run the below command
```
ldconfig /usr/local/lib
```
# IP2Location CLI
Query an IP address and display the result
```
ip2location -d [IP2LOCATION BIN DATA PATH] --ip [IP ADDRESS]
```
Query all IP addresses from an input file and display the result
```
ip2location -d [IP2LOCATION BIN DATA PATH] -i [INPUT FILE PATH]
```
Query all IP addresses from an input file and display the result in XML format
```
ip2location -d [IP2LOCATION BIN DATA PATH] -i [INPUT FILE PATH] --format XML
```
# References
##### Address Type
Address type is the IP address types as defined in Internet Protocol version 4 (IPv4) and Internet Protocol version 6 (IPv6). The database return a single character. For the full description, please refer to list below:
- (A) Anycast - One to the closest
- (U) Unicast - One to one
- (M) Multicast - One to multiple
- (B) Broadcast - One to all
##### Category
Category is the domain category is based on [IAB Tech Lab Content Taxonomy](https://www.ip2location.com/free/iab-categories). These categories are comprised of Tier-1 and Tier-2 (if available) level categories widely used in services like advertising, Internet security and filtering appliances. Please refer to https://www.ip2location.com/free/iab-categories for the full list.
# Packages for Fedora/Enterprise Linux can be found here
* https://koji.fedoraproject.org/koji/packageinfo?packageID=32132
* https://src.fedoraproject.org/rpms/IP2Location
* https://bodhi.fedoraproject.org/updates/?packages=IP2Location
# Support
Email: [email protected].
URL: [https://www.ip2location.com](https://www.ip2location.com)