User Tools

Site Tools


howtos:get_all_danish_ip_subenets

Get the whole list:

wget ftp://ftp.ripe.net/pub/stats/ripencc/delegated-ripencc-latest

Parse it with the following script:

grep DK.ipv4 delegated-ripencc-latest | awk -F'|' -vOFS=/ '{print $4,32- log($5)/log(2)}' | while read network; do whois --verbose -h whois.ripe.net -T route -x $network >>danske_netblokke 2>&1; sleep 2; done

Now extract the IP subents:

cat danske_netblokke |grep route: | cut -d: -f2| sed 's/[[:space:]]//g'

One-liner for DK:

curl --silent https://stat.ripe.net/data/country-resource-list/data.json?resource=dk |grep -Eo  '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/([0-9]|[1-3][0-9])'| column -c 280

Change the resource=xx to the country you would like to extract (https://en.wikipedia.org/wiki/ISO_3166-2).

The last part “column -c 280” can be excluded to get the list in one row.

howtos/get_all_danish_ip_subenets.txt · Last modified: 02/12/2018 20:34 by 127.0.0.1