I am trying to figure out how to resolve a subnet for a specific domain on my CentOS machine. for example Google owns a range of IP addresses and one range in particular is
18.104.22.168 - 22.214.171.124. Now they also have many more but I will just talk about this range for the question.
What I was originally trying to do was have this range in the /etc/hosts file with the hostname
The reason for the importance on this is we have a product that tracks IP addresses users visit and we want to chart the data on a tree map, but instead of the chart showing
126.96.36.199 we want it to display
The only lead I have so far is using the /etc/hosts file but I do not want to single handily type out every single address for Google, then Facebook and so on. Is there another way I could achieve my goal, making life a lot easier for me?
I think you could easily query RADb for this. Get the ASN for each IP address, and just work with those.
$ whois -h whois.radb.net 188.8.131.52 [Querying whois.radb.net] [whois.radb.net] route: 184.108.40.206/14 descr: Qwest Communications 950 17th Street Suite 1900 Denver, CO 80202 origin: AS209 mnt-by: MAINT-QWEST changed: email@example.com 20020504 source: RADB
Here we see that this IP is in AS209 (which you can store instead of the IP, or in addition to it, if you wish) and is registered to Qwest Communications, which you can then display.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.