4 203
modifications
Aucun résumé des modifications |
Aucun résumé des modifications |
||
Ligne 23 : | Ligne 23 : | ||
logpath = /var/log/auth.log | logpath = /var/log/auth.log | ||
maxretry = 6 | maxretry = 6 | ||
</pre> | |||
=Compléments= | |||
Si une ip vous harcèle, vous pouvez la bannir définitivement avec iptables. Pour simplifier les opérations, j'ai créé un petit script bash : | |||
<pre> | |||
#! /bin/sh | |||
me=`dirname $0`/ | |||
case "$1" in | |||
start) | |||
iptables -N morales | |||
iptables -A INPUT -p tcp -m multiport --dports ssh,telnet,ftp,ftp-data,ftps,http,https,pop3,pop3s,imap,imaps,submission -j morales | |||
if [ -f "$me/banned.list" ]; then | |||
for ligne in `cat $me/banned.list`; do | |||
iptables -A morales -s $ligne -j DROP | |||
done | |||
else | |||
touch $me/banned.list | |||
fi | |||
echo "Started" | |||
exit 0 | |||
;; | |||
stop) | |||
iptables -F morales | |||
iptables -D INPUT -p tcp -m multiport --dports ssh,telnet,ftp,ftp-data,ftps,http,https,pop3,pop3s,imap,imaps,submission -j morales | |||
iptables -X morales | |||
echo "Stopped" | |||
exit 0 | |||
;; | |||
restart) | |||
$0 stop | |||
$0 start | |||
exit 0 | |||
;; | |||
add) | |||
if [ "$2" = "" ]; then | |||
echo "Usage: $0 add <ip>" | |||
exit 1 | |||
fi | |||
iptables -A morales -s $2 -j DROP | |||
if [ "$?" = "0" ]; then | |||
echo $2 >> $me/banned.list | |||
echo "Added $2" | |||
exit 0 | |||
else | |||
echo "Error" | |||
exit 1 | |||
fi | |||
exit 0 | |||
;; | |||
del) | |||
if [ "$2" = "" ]; then | |||
echo "Usage: $0 del <ip>" | |||
exit 1 | |||
fi | |||
iptables -D morales -s $2 -j DROP | |||
if [ "$?" = "0" ]; then | |||
sed /$2/d $me/banned.list > $me/banned.list.tmp | |||
mv $me/banned.list.tmp $me/banned.list | |||
echo "Removed $2" | |||
exit 0 | |||
else | |||
echo "Error" | |||
exit 1 | |||
fi | |||
exit 0 | |||
;; | |||
flush) | |||
iptables -F morales | |||
rm -f $me/banned.list | |||
touch $me/banned.list | |||
echo "ok" | |||
exit 0 | |||
;; | |||
list) | |||
echo "Currently banned ips :" | |||
iptables -L morales | |||
exit 0 | |||
;; | |||
*) | |||
echo "Usage: $0 {start|stop|restart|add|del|flush|list}" | |||
exit 1 | |||
;; | |||
esac | |||
</pre> | </pre> |