Bonjour ! j’ai un serveur debian jessie et j’ai constamment des scan de port bloqués avec portsentry, mais je voudrais bloquer les ip de pays, et je ne sais pas trop comment m’y prendre; j’ai trouvé ça sur le site :
Qu’en pensez vous , et surtout étant encore novice comment dois-je l’installer ?
merci d’avance !
#!/bin/bash
Block tout traffic de AFGHANISTAN (af), RUSSE (ru), and CHINA (cn).
ISO=“af cn ru”
PATH
IPT=/sbin/iptables
WGET=/usr/bin/wget
EGREP=/bin/egrep
Adapter
SPAMLIST=“countrydrop"
ZONEROOT=”/root/iptables"
DLROOT=“http://www.ipdeny.com/ipblocks/data/countries”
create a dir
[ ! -d $ZONEROOT ] && /bin/mkdir -p $ZONEROOT
create a new iptables list
iptables -N $SPAMLIST
for c in $ISO
do
# local zone file
tDB=$ZONEROOT/$c.zone
# get fresh zone file
$WGET -O $tDB $DLROOT/$c.zone
country specific log message
SPAMDROPMSG="$c Country Drop"
get
BADIPS=$(egrep -v “^#|^$” $tDB)
for ipblock in $BADIPS
do
iptables -A $SPAMLIST -s $ipblock -j LOG --log-prefix "$SPAMDROPMSG"
iptables -A $SPAMLIST -s $ipblock -j DROP
done
done
Drop
iptables -I INPUT -j $SPAMLIST
iptables -I OUTPUT -j $SPAMLIST
iptables -I FORWARD -j $SPAMLIST
exit 0