User Tools

Site Tools


wiki:whois_lookup_list_ips_find_countries

whois lookup on list of IPs and find countries

For a list of IPs in file like this:

115.73.43.82
171.226.37.107
116.100.13.224
171.252.244.192
27.75.96.60
115.73.181.107
27.64.204.111
116.177.225.197
27.65.174.108
115.72.36.7
...

do a lookup with whois

for ip in $(cat list);do whois $ip |awk -F: '/country/ {print $2}'| sort;done > sorted1.txt

Then show sorted and aggregated.

cat sorted1.txt |sort|uniq -c

If you get an error like:

No whois server is known for this kind of object.

Could be the input file is messed up. Use this command instead:

while IFS=$' \t\r\n' read -r ip; do whois $ip |awk -F: '/country/ {print $2}'| sort; done < list > sorted

Tested on

  • Ubuntu 20.04

See also

References

wiki/whois_lookup_list_ips_find_countries.txt · Last modified: 2022/04/25 11:41 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki