Filter ASN database based on a single ASN

Get IP addresses by looking up a single ASN from IP to ASN (Free) and the ASN database (Paid)

asn_filtered_database (1)

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<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


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