Get the IP addresses of multiple ASNs from the IP to ASN (Free) and the ASN database (Premium)
If you want to create an AS-filtered database with a combination of multiple of ASes, follow the instructions below.
Step 1: Download the CSV format of your ASN database.
Here I am downloading the IP to ASN database.
curl -L https://ipinfo.io/data/free/asn.csv.gz?token=<YOUR_TOKEN> -o asn.csv.gz
Step 2: Unzip the .gz
database.
I am using the CLI utility gunzip
, but you can use whatever compression software or tool you want to use.
gunzip asn.csv.gz
Step 3: Create a .txt
file that contains the ASN you want to select
Create an asns.txt
file that contains your desired ASNs. For example:
AS36473
AS12054
AS207137
Step 4: Filter the IP database with the selected ASNs
Using grep
like before, we will create the filtered database. However, we are going to use the -f
option, which stands for “fixed strings” and pass our asns.txt
file containing the selected ASNs.
(head -1 asn.csv;grep -f asns.txt asn.csv) > filtered_asns.csv
Protip:
You can skip the uncompressing step and run grep on the compressed file with zgrep
. Here I am running the grep on the compressed asn.csv.gz
database and viewing it one less
.
zgrep -f asns.txt asn.csv | less
IPinfo Database Downloads
- Open access IP to ASN Database
- Open access IP to Country ASN Database
- Premium ASN Database (Comes with AS type and AS country)