IP2Location™ LITE IP-ASN Database

介绍

ASN Database

该数据库提供了确定自治系统和编号(ASN)的参考。自治系统(AS)是在一个或多个网络运营商的控制下作为路由策略中的单个管理实体而连接的Internet协议(IP)路由前缀的集合。

ASN.LITE版本已获得Creative Commons Attribution-ShareAlike 4.0 International License许可。对于个人或商业用途,它是免费的,但需注明出处并注明出处,如下所述,

特征

将IP地址转换为自治系统(AS)和自治系统编号(ASN)。

当前版本 August 2021
数据库大小 9.32 MB (606,852 Rows)
数据库格式 ASCII文本文件(以逗号分隔)和二进制(BIN)

数据库字段

名称 类型 描述
ip_from INT (10) / DECIMAL (39,0)†† 第一个IP地址显示netblock。
ip_to INT (10) / DECIMAL (39,0)†† 上一个IP地址显示netblock。
cidr VARCHAR(43) CIDR中的IP地址范围。
asn INT(10) 自治系统号(ASN)。
as VARCHAR(256) 自治系统(AS)名称。

IPv4
†† IPv6

数据库设置

以下是为IPv4和IPv6数据设置数据库的步骤。

建立资料库
CREATE DATABASE ip2location;
USE ip2location;
CREATE TABLE `ip2location_asn`(
	`ip_from` INT(10) UNSIGNED,
	`ip_to` INT(10) UNSIGNED,
	`cidr` VARCHAR(43),
	`asn` VARCHAR(10),
	`as` VARCHAR(256),
	INDEX `idx_ip_from` (`ip_from`),
	INDEX `idx_ip_to` (`ip_to`),
	INDEX `idx_ip_from_to` (`ip_from`, `ip_to`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
导入数据库
LOAD DATA LOCAL
	INFILE 'IP2LOCATION-LITE-ASN.CSV'
INTO TABLE
	`ip2location_asn`
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 0 LINES;
建立资料库
CREATE DATABASE ip2location
GO

USE ip2location
GO

CREATE TABLE [ip2location].[dbo].[ip2location_asn](
	[ip_from] bigint NOT NULL,
	[ip_to] bigint NOT NULL,
	[cidr] nvarchar(43) NOT NULL,
	[asn] nvarchar(10) NOT NULL,
	[as] nvarchar(256) NOT NULL
) ON [PRIMARY]
GO

CREATE CLUSTERED INDEX [ip_to] ON [ip2location].[dbo].[ip2location_asn]([ip_to]) ON [PRIMARY]
GO
导入数据库
BULK INSERT [ip2location].[dbo].[ip2location_asn]
FROM '{PATH TO IP2LOCATION-LITE-ASN.CSV}'
WITH
(
	FORMATFILE = '{PATH TO ASN.FMT}'
)
GO

注意:您将需要复制以下FMT代码并将其保存为计算机上名为ASN.FMT的文件。

12.0
6
1 SQLCHAR 0 1 "\"" 0 first_double_quote  Latin1_General_CI_AI
2 SQLCHAR 0 20 "\",\"" 1 ip_from "",
3 SQLCHAR 0 20 "\",\"" 2 ip_to "",
4 SQLCHAR 0 43 "\",\"" 3 cidr Latin1_General_CI_AI,
5 SQLCHAR 0 10 "\",\"" 4 asn Latin1_General_CI_AI,
6 SQLCHAR 0 256 "\",\"" 5 as Latin1_General_CI_AI

建立资料库
CREATE DATABASE ip2location WITH ENCODING 'UTF8';
\c ip2location
CREATE TABLE ip2location_asn(
	ip_from bigint NOT NULL,
	ip_to bigint NOT NULL,
	cidr character varying(43) NOT NULL,
	asn character varying(10) NOT NULL,
	as character varying(256) NOT NULL,
	CONSTRAINT ip2location_db1_pkey PRIMARY KEY (ip_from, ip_to)
);
导入数据库
COPY ip2location_asn FROM 'IP2LOCATION-LITE-ASN.CSV' WITH CSV QUOTE AS '"';
建立资料库
CREATE DATABASE ip2location;
USE ip2location;
CREATE TABLE `ip2location_asn_ipv6`(
	`ip_from` DECIMAL(39,0) UNSIGNED,
	`ip_to` DECIMAL(39,0) UNSIGNED,
	`cidr` VARCHAR(43),
	`asn` VARCHAR(10),
	`as` VARCHAR(256),
	INDEX `idx_ip_from` (`ip_from`),
	INDEX `idx_ip_to` (`ip_to`),
	INDEX `idx_ip_from_to` (`ip_from`, `ip_to`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
导入数据库
LOAD DATA LOCAL
	INFILE 'IP2LOCATION-LITE-ASN.IPV6.CSV'
INTO TABLE
	`ip2location_asn_ipv6`
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 0 LINES;
建立资料库
CREATE DATABASE ip2location
GO

USE ip2location
GO

CREATE TABLE [ip2location].[dbo].[ip2location_asn_ipv6](
	[ip_from] char(39) NOT NULL,
	[ip_to] char(39) NOT NULL,
	[cidr] nvarchar(43) NOT NULL,
	[asn] nvarchar(10) NOT NULL,
	[as] nvarchar(256) NOT NULL
) ON [PRIMARY]
GO

CREATE CLUSTERED INDEX [ip_to] ON [ip2location].[dbo].[ip2location_asn_ipv6]([ip_to]) ON [PRIMARY]
GO
导入数据库
BULK INSERT [ip2location].[dbo].[ip2location_asn_ipv6]
FROM '{PATH TO IP2LOCATION-LITE-ASN.IPV6.CSV}'
WITH
(
	FORMATFILE = '{PATH TO ASN.FMT}'
)
GO

注意:您将需要复制以下FMT代码并将其保存为计算机上名为ASN.FMT的文件。 FMT代码的第一行指示bcp的版本。请根据安装的MS-SQL更改版本。

12.0
6
1 SQLCHAR 0 1 "\"" 0 first_double_quote  Latin1_General_CI_AI
2 SQLCHAR 0 39 "\",\"" 1 ip_from "",
3 SQLCHAR 0 39 "\",\"" 2 ip_to "",
4 SQLCHAR 0 43 "\",\"" 3 cidr Latin1_General_CI_AI,
5 SQLCHAR 0 10 "\",\"" 4 asn Latin1_General_CI_AI,
6 SQLCHAR 0 256 "\",\"" 5 as Latin1_General_CI_AI

建立资料库
CREATE DATABASE ip2location WITH ENCODING 'UTF8';
\c ip2location
CREATE TABLE ip2location_asn_ipv6(
	ip_from decimal(39,0) NOT NULL,
	ip_to decimal(39,0) NOT NULL,
	cidr character varying(43) NOT NULL,
	asn character varying(10) NOT NULL,
	as character varying(256) NOT NULL,
	CONSTRAINT ip2location_db1_pkey PRIMARY KEY (ip_from, ip_to)
);
导入数据库
COPY ip2location_asn_ipv6 FROM 'IP2LOCATION-LITE-ASN.IPV6.CSV' WITH CSV QUOTE AS '"';

IP2Location IP地址地理位置数据库

在商业版中,您将获得的不仅仅是IP地址查找:

  • 更高的数据准确性
  • 访问最新数据库
  • 通过电子邮件获得更多支持
Product Upgrade