Get IP address Space By AS(Autonomous System) Number

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:


....
69.63.176.0/20
69.63.176.0/21
69.63.184.0/21
66.220.144.0/20
69.63.176.0/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.

Sources:

https://stackoverflow.com/questions/11164672/list-of-ip-space-used-by-facebook
https://gist.github.com/normoes/829d65866c8bf6d32b13f020479b172b
https://developers.facebook.com/docs/sharing/webmasters/crawler