Skip to content

Instantly share code, notes, and snippets.

@RalphORama
Created January 19, 2022 18:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RalphORama/83cf5a553ccd461fcc962b4caea9f09f to your computer and use it in GitHub Desktop.
Save RalphORama/83cf5a553ccd461fcc962b4caea9f09f to your computer and use it in GitHub Desktop.
Block traffic from AS12876 (scaleway)
#!/bin/bash
set -e
if [ "$EUID" -ne 0 ]; then
echo "run this script as root!"
exit 1
fi
# ranges collected from https://ipinfo.io/AS12876
as12876_v4=(
"151.115.0.0/18"
"163.172.0.0/16"
"163.172.208.0/20"
"195.154.0.0/16"
"212.129.0.0/18"
"212.47.224.0/19"
"212.83.128.0/19"
"212.83.160.0/19"
"51.15.0.0/16"
"51.15.0.0/17"
"51.158.0.0/15"
"51.158.128.0/17"
"62.210.0.0/16"
"62.4.0.0/19"
)
as12876_v6=(
"2001:bc8:1400::/38"
"2001:bc8:1800::/38"
"2001:bc8:1c00::/38"
"2001:bc8::/32"
)
echo "Blocking AS12876 IPv4 ranges..."
for ip in "${as12876_v4[@]}"; do
iptables -I INPUT -s "$ip" -j DROP
done
echo "Blocking AS12876 IPv6 ranges..."
for ip in "${as12876_v6[@]}"; do
ip6tables -I INPUT -s "$ip" -j DROP
done
echo "Done! Printing results..."
iptables -S INPUT
ip6tables -S INPUT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment