Compile a list of all Facebook-owned IPs

July 20, 2018    Article    96 words    1 min read

Sometimes you want to block all Facebook IPs for various reasons (1, 2, 3, 4, 5, 6, 7, 8). Sometimes you really really do want that (and you should do it), so compiling a list with all the IPs is easy (both IPv4 and IPv6):

$ whois -h whois.radb.net '!gAS32934' | \
	tr ' ' '\n' | \
	awk '!/[[:alpha:]]/' > facebook-ips-ipv4.txt
$ whois -h whois.radb.net '!6AS32934' | \
	tr ' ' '\n' | \
	grep '::' > facebook-ips-ipv6.txt

And a list of Facebook-owned IPs will be saved into the facebook-ips-{ipv4/ipv6}.txt files, ready to be used.