How to collect Location, Country or ISP IP Ranges

All IPs of a city, a state or another locations

Download and unpack City Geolocation Database:

wget `curl -s https://db-ip.com/db/download/city | grep -E -o 'http://download.db-ip.com/free/dbip-city-20[0-9]{2}-[0-9]{2}.csv.gz'`&& gunzip dbip-city-*.csv.gz && mv dbip-city-* dbip-city-csv

Now insert in the commplex command any location name. For instance, I want to know all IPs of Paris, so I do

cat dbip-city-csv | grep -E -i "Paris" | sed 's/","/-/' | cut -d ',' -f 1 | sed 's/"//' | sed 's/"//'

You can save all ranges in a file, just redirect output:

cat dbip-city-csv | grep -E -i "Paris" | sed 's/","/-/' | cut -d ',' -f 1 | sed 's/"//' | sed 's/"//' > file.txt

Replace 'Paris' to any location interests you.

You can check the entire contents of matching lines:

cat dbip-city-csv | grep -E -i "Paris"

All IPs of a country

Download and unpack Country Geolocation Database:

wget `curl -s https://db-ip.com/db/download/country | grep -E -o 'http://download.db-ip.com/free/dbip-country-20[0-9]{2}-[0-9]{2}.csv.gz'` && gunzip dbip-country-*csv.gz && mv dbip-country-* dbip-country-csv

Use the following complex command to obtain Country IP Ranges, replace UK to two-letter country code

COUNTRY=UK;cat dbip-country-csv | grep -E "$COUNTRY" | sed 's/","/-/' | sed 's/`echo $COUNTRY`//' | cut -d ',' -f 1 | sed 's/"//' | sed 's/"//' > IP_Country_$COUNTRY.txt

For example, TH for Thailand:

COUNTRY=TH;cat dbip-country-csv | grep -E "$COUNTRY" | sed 's/","/-/' | sed 's/`echo $COUNTRY`//' | cut -d ',' -f 1 | sed 's/"//' | sed 's/"//' > IP_Country_$COUNTRY.txt

All ISP IP Ranges

To obtain all ISP IP ranges you need to know web-site address of ISP or any IP belongs to it.

For example

curl -s -L --data "www.parc.com" https://2ip.ua/ru/services/information-service/provider-ip?a=act | grep -o -E '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/[0-9]{1,2}'

Replace www.parc.com to ISP web-site address or any IP belongs to the ISP.

Free online service to obtain information about IPs and to build IP ranges of localities, country and ISP IP ranges

You can use for free suip.biz to obtain location, country or ISP IP ranges.

Recommended for you:

One Comment to How to collect Location, Country or ISP IP Ranges

  1. webmast552 says:

    thank a lot bro, u just make my day^^

Leave a Reply

Your email address will not be published. Required fields are marked *