|
Nous allons installer fail2ban-0.8.4 pour compléter l'outil existant sur DSM 3.0 "Blocage auto". Fail2ban va permettre par exemple de bloquer les tentatives de connexion (brute force) sur votre site web, webmail... et ainsi vous protéger de nombreuses attaques.
ipkg install python26 ln -s /opt/bin/python2.6 /usr/bin/python cd /opt/share/ wget http://downloads.sourceforge.net/project/fail2ban/fail2ban-stable/fail2ban-0.8.4/fail2ban-0.8.4.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Ffail2ban%2Ffiles%2Ffail2ban-stable%2Ffail2ban-0.8.4%2F&ts=1291202065&use_mirror=ovh tar jxvf fail2ban-0.8.4.tar.bz2
ou
sudo apt-get install fail2ban
Fichier de configuration jail.conf
[DEFAULT]
ignoreip = 127.0.0.1 192.168.1.100 # en seconde : 7200 (2h) 86400 (1j) bantime = 86400 findtime = 600 maxretry = 2 backend = auto
mta = mail destemail =
Cette adresse email est protégée contre les robots des spammeurs, vous devez activer Javascript pour la voir.
action = iptables-allports %(mta)s[name=%(__name__)s, dest="%(destemail)s"]
[roundcubemail] enabled = true filter = roundcubemail logpath = /usr/syno/synoman/phpsrc/roundcubemail-0.5-beta/logs/errors
[MyHostWebaccess] enabled = true filter = MyHostWebaccess logpath = /volume1/web/logs/MyHostwebAccess.log
Supprimer banissment: iptables -L --line-number iptables -D "fail2ban-default" num
Démarrer le démon
ln -s /opt/share/fail2ban-0.8.4/fail2ban-client /usr/bin/fail2ban cd /opt/share/fail2ban-0.8.4/ ./fail2ban-client -c config/ start
/etc/init.d/fail2ban-server restart
Création d'une règle pour le site web
webaccess.conf dans le répertoire /opt/share/fail2ban-0.8.4/filter.d/ contenant : [Definition] # Option: failregex # Notes.: regex to match the password failures messages in the logfile. The # host must be matched by a group named "host". The tag "" can # be used for standard IP/hostname matching. # Values: TEXT # failregex = webaccess authentification failure; rhost= # Option: ignoreregex # Notes.: regex to ignore. If this regex matches, the line is ignored. # Values: TEXT # ignoreregex =
Dans /opt/share/fail2ban-0.8.4/config/jail.conf, ajoutez:
[webaccess]
enabled = true port = http filter = webaccess logpath = /var/www/myhost_cms/logs/MyHostwebAccess.log
Problème de démarrage
Créer les liens pour que python trouve les dépendances
ln -s /opt/share/fail2ban-0.8.4/server/ /opt/lib/python2.6/server ln -s /opt/share/fail2ban-0.8.4/client/ /opt/lib/python2.6/client ln -s /opt/share/fail2ban-0.8.4/common/ /opt/lib/python2.6/common
Le synology utilise un autre sytème de blocage d'IP:
Vous pouvez trouver un exemple dans l'application web photo (/usr/syno/synoman/phpsrc/photo/m/ajax/login.php):
$commend = "/usr/syno/bin/synoautoblock --attempt \"".$_SERVER['REMOTE_ADDR']."\""; $commend = "/usr/syno/bin/synoautoblock --reset \"".$_SERVER['REMOTE_ADDR']."\""; @system($commend, $retval);
Testé sur le NAS synology DS 411+
|