rusia block ips

master
fanta 2 weeks ago
parent d462bab656
commit c5ade6a5a1

@ -0,0 +1,3 @@
# ruBlock
bash script para bloquear rusia con iptables

@ -0,0 +1,27 @@
#!/bin/bash
# fanta <fanta@56k.es>
# ru block - Para bloquear toda Rusia con iptables. Ejecutar como root
# dependencies: bash wget curl iptables
ipListUrl="https://www.ipdeny.com/ipblocks/data/countries/ru.zone"
function main(){
checkURL
downloadIPList
blockIP
}
function checkURL(){
errorCode=$(curl -kiss $ipListUrl | head -1 | cut -d " " -f 2)
if [ $errorCode != 200 ]; then echo "URL not found $ipListUrl"; exit; fi
}
function downloadIPList(){
wget -q "$ipListUrl" -O /tmp/.ips > /dev/null 2>&1
}
function blockIP(){
while read -r ip; do echo "DROP $ip"; iptables -A INPUT -s $ip -j DROP; done < /tmp/.ips
}
main
Loading…
Cancel
Save