Skip to content

Instantly share code, notes, and snippets.

@Cvetomird91
Last active June 28, 2018 08:27
Show Gist options
  • Save Cvetomird91/a618fc2d89842f5eba0bcde8a8e68c94 to your computer and use it in GitHub Desktop.
Save Cvetomird91/a618fc2d89842f5eba0bcde8a8e68c94 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
ip_ranges=($(whois -h whois.radb.net -- '-i origin AS32934' | grep ^route: | awk '{print $2}'));
ranges=();
for ip_range in ${ip_ranges[@]}; do
MINADDR=$(ipcalc --minaddr ${ip_range} | awk -F'=' '{print $2}');
MAXADDR=$(ipcalc --maxaddr ${ip_range} | awk -F'=' '{print $2}');
RANGE="${MINADDR}-${MAXADDR}";
ranges=( "${ranges[@]}" "${RANGE}" );
done
iptables -N FACEBOOK
for range in ${ranges[@]}; do
iptables -I FORWARD -m tcp -p tcp -m iprange --dst-range "${range}" --dport 80 -j FACEBOOK
iptables -I FORWARD -m tcp -p tcp -m iprange --dst-range "${range}" --dport 443 -j FACEBOOK
done
iptables -A FACEBOOK -j REJECT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment