Sometimes you need to get all possible address blocks of a network but most of the time there is no easy way to figure it out, looking at you Facebook and Google, but fear not sysadmin we have one handy trick up in our sleeve, by using whois with the AS number of the company we can build this kind of list.
We’ll use Facebook(AS32934) as an example, but it should work for any Autonomous System.
whois -h whois.radb.net -- "-i origin AS32934" | grep ^route | tr -s " " | cut -d " " -f2-
The output should look like this:
.... 22.214.171.124/20 126.96.36.199/21 188.8.131.52/21 184.108.40.206/20 220.127.116.11/20 2620:0:1c00::/40 2a03:2880::/32 2a03:2880:fffe::/48 2a03:2880:ffff::/48 2620:0:1cff::/48 ....
And with this you have the full list of networks assigned to the AS, you can block/redirect/prioritize as you see fit, and as with most lists this is not a static one so you should build a script and update it from time to time.