Grabbing CIDR blocks from AS
February 13, 2023 —
~cyberspelunker
set up
bgp.tools provides two handy files at bgp.tools/asns.csv and bgp.tools/table.txt
grab a copy of each with wget.
wget https://bgp.tools/table.txt
wget https://bgp.tools/asns.csv
Find AS values for query string of interest and save to a file.
grep -Ei pipeline asns.csv | tee orgs.txt
extract the number only from the ASxxx results in prior step and find the CIDR values for each AS number and output to file.
grep -Ei -o '^AS[0-9]*' orgs.txt | sed 's#AS##g' | xargs -I {} grep -Ei ' {}$' table.txt | tee ASnetblocks.txt
Tags: spelunking-tips