Get IP addresses by looking up a single ASN from IP to ASN (Free) and the ASN database (Paid)
If you want to filter the ASN database based on one ASN, 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: Filter the IP database with the AS you have selected
After uncompressing the database, we get the asn.csv
file. Using grep
we will extract the IP data rows for the ASN. We are using the ASN **AS24940.
We will use the head
command to get the CSV column headers. Then we will combine the column headers and output from the grep
command to a filtered_asn.csv
database.
(head -1 asn.csv;grep ",AS24940," asn.csv) > filtered_asn.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 ",AS24940," asn.csv.gz | less
Downloads
- Open access IP to ASN Database
- Open access IP to Country ASN Database
- Premium ASN Database (Comes with AS type and AS country)