1 Introduction
This document describes IPWorks AAA Server Geography data. The data are contained in two Comma-Separated Values (CSV) files:
- <Geography_IP>.csv: It contains the Geography IP data.
- <Anonymous_Proxy>.csv: It contains the Anonymous proxy data.
The CSV format follows the definition in RFC 4180 Common Format and MIME Type for CSV Files with the following restrictions:
- Header line is mandatory, where the first line of the CSV file contains the name of fields.
- Each field cannot be enclosed in double quotes.
IPWorks AAA Server does not provide Geography data. The customer can acquire data from third-party Geography data provider and translate the data as specific format defined in this document. Then, the Geography data is imported into the Internal Geography DB of IPWorks AAA Server.
This document only describes the CSV files with IPWorks specific format.
1.1 Prerequisites
Not Applicable.
1.2 Related Information
Trademark information, typographic conventions, definition, and explanation of acronyms and terminology can be found in the following documents:
2 Concept
The Geography IP is the mapping from IP address to physical address of registrant in form of ISO 3166-1 alpha-2 Country Code.
The Anonymous proxy is a tool that attempts to make activity on the network untraceable. It is a proxy server computer that acts as an intermediary between a client device and the rest of the network. Anonymous proxy accesses the target network on behalf of user and hides the identifying information of the client computer, for example, the user IP address.
3 IPWorks AAA Server Geography Data
3.1 Geography IP CSV File
Header line of Geography IP CSV File has two fields. The first field is subnet and the second field is iso_cc. The detail is defined in Table 1.
|
Field Number |
Field Name |
Description |
Example |
|---|---|---|---|
|
1 |
subnet |
All IPv4 addresses in a subnetwork belong to the same country. It is written as the first address of a network, followed by a slash character (/), and ended with the bit-length of the prefix. No network overlap is allowed for any 2 subnets. |
1.0.1.0/24 The first IP is 1.0.1.0. The last IP is 1.0.1.255. |
|
2 |
iso_cc |
Country Code in format of ISO 3166-1 alpha-2 standard. |
For example:
# cat ./aaageoipv4.csv
subnet, iso_cc 1.0.0.0/24, AU 1.0.1.0/24, CN …
3.2 Anonymous Proxy CSV File
Header line of Anonymous Proxy CSV File has one field subnet. The detail is defined in Table 2.
|
Field Name |
Description |
Example |
|---|---|---|
|
subnet |
All IP addresses in a subnetwork are anonymous proxies. It is written as the first address of a network, followed by a slash character (/), and ended with the bit-length of the prefix. No network overlap is allowed for any 2 subnets. |
1.169.65.4/32 The first IP is 1.169.65.4. The last IP is 1.169.65.4. |
For example:
# cat ./ aaaanonproxyipv4.csv
subnet 1.9.21.21/32 1.169.65.4/32 …
4 Appendix
4.1 Tool to Import IPWorks AAA Server Geography Data
Usage: /opt/ipworks/IPWss/db/geoip/load_geoip_data.py -f <CSV_FILENAME> -t <AAA_DB_TABLENAME>
With:
|
CSV_FILENAME |
The filename of IPWorks 3GPP AAA Geography data, for example, /tmp/aaageoipv4.csv |
|
AAA_DB_TABLENAME |
The table name must be aaageoipv4 for IPWorks AAA Server Geography IP data. The table name must be aaaanonproxyipv4 for IPWorks AAA Server Anonymous Proxy data. |
4.2 Example Code
4.2.1 Convert MaxMind GeoIP2 DB to IPWorks Specific Format
#!/usr/bin/python
import csv
output_ipworks_geoipv4_filename = "./aaageoipv4.csv"
input_maxmind_geoip_cc_filename= "./Geo-Country-Locations-en.csv"
input_maxmind_geoip_cb_filename= "./Geo-Country-Blocks-IPv4.csv"
file_out = open(output_ipworks_geoipv4_filename,"w")
dic_isocc={}
with open(input_maxmind_geoip_cc_filename) as fi_isocc:
for each_isocc in csv.DictReader(fi_isocc):
if each_isocc['geoname_id'] == "":
raise csv.Error("The value of 'geoname_id' is empty, it's invalid")
dic_isocc[each_isocc['geoname_id']] = each_isocc['country_iso_code']
file_out.write("subnet,iso_cc\n")
with open(input_maxmind_geoip_cb_filename) as fi_network:
for each_network in csv.DictReader(fi_network):
try:
if each_network['geoname_id'] == "":continue
file_out.write(each_network['network']+','+dic_isocc[each_network['geoname_id']]+'\n')
except KeyError as e:
raise csv.Error('Key: %s is not exist in file %s' % (e, input_maxmind_geoip_cc_filename))
file_out.close()
|
4.2.2 Convert MaxMind Anonymous IP DB to IPWorks Specific Format
#!/usr/bin/python
|
output_ipworks_anonproxy_filename = "./aaaanonproxyipv4.csv"
input_maxmind_anonproxy_filename= "./GeoIP2-Anonymous-IP-Blocks-IPv4.csv"
file_in = open(input_maxmind_anonproxy_filename)
file_out = open(output_ipworks_anonproxy_filename,"w")
file_out.write("subnet\n")
for each in file_in.readlines()[1:]:
fields = map(str.strip, each.split(","))
# field[0]:network
# field[1]:is_anonymous
if (fields[1] == '1'):
file_out.write(fields[0]+'\n')
|

Contents

