Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 06/05/2016, à 15:24

Narumi

[résolu] Fail2ban problème ban

Bonjour,

J'ai ubuntu server d'installé avec iptables et fail2ban mais fail2ban ne bannit pas les ip automatiquement.
si je bannis une ip manuellement, ça fonctionne.



Voici mon fichier pour iptables et d'autres informations.

Je vous remercie d'avance pour votre aide.


# Vider les tables actuelles
iptables -t filter -F

# Vider les règles personnelles
iptables -t filter -X

# Interdire toute connexion entrante et sortante
iptables -t filter -P INPUT DROP
iptables -t filter -P FORWARD DROP
iptables -t filter -P OUTPUT DROP

# ---

# Ne pas casser les connexions etablies
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

# Autoriser loopback
iptables -t filter -A INPUT -i lo -j ACCEPT
iptables -t filter -A OUTPUT -o lo -j ACCEPT

# ICMP (Ping)
iptables -t filter -A INPUT -p icmp -j ACCEPT
iptables -t filter -A OUTPUT -p icmp -j ACCEPT

# ---

# SSH In
iptables -t filter -A INPUT -p tcp --dport 22 -j ACCEPT

# SSH Out
iptables -t filter -A OUTPUT -p tcp --dport 22 -j ACCEPT

# DNS In/Out
iptables -t filter -A OUTPUT -p tcp --dport 53 -j ACCEPT
iptables -t filter -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -t filter -A INPUT -p udp --dport 53 -j ACCEPT

# NTP Out
iptables -t filter -A OUTPUT -p udp --dport 123 -j ACCEPT



# HTTP + HTTPS Out
iptables -t filter -A OUTPUT -p tcp --dport 80 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 443 -j ACCEPT

# HTTP + HTTPS In
iptables -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 8443 -j ACCEPT

Voici une partie de mon fichier jail.local

# SSH
# 3 retry > Ban for 15 minutes
[ssh]

enabled = true
port = ssh
filter = sshd
action   = iptables[name=SSH, port=ssh, protocol=tcp]
logpath  = /var/log/auth.log
maxretry = 3
bantime = 3600

#

J'ai banni cette ip manuellement.

:/etc/fail2ban# iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination
f2b-SSH    tcp  --  anywhere             anywhere             tcp dpt:ssh
f2b-sshd   tcp  --  anywhere             anywhere             multiport dports ssh
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain
ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:https
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:8443

Chain FORWARD (policy DROP)
target     prot opt source               destination

Chain OUTPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain
ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
ACCEPT     udp  --  anywhere             anywhere             udp dpt:ntp
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:https

Chain f2b-SSH (1 references)
target     prot opt source               destination
REJECT     all  --  120.25.250.28        anywhere             reject-with icmp-port-unreachable
RETURN     all  --  anywhere             anywhere

Chain f2b-sshd (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Voici mon fichier auth.log

ay  6 16:18:01 a CRON[1792]: pam_unix(cron:session): session closed for user root
May  6 16:19:01 a CRON[1835]: pam_unix(cron:session): session opened for user root by (uid=0)
May  6 16:19:01 a CRON[1835]: pam_unix(cron:session): session closed for user root
May  6 16:20:01 a CRON[1878]: pam_unix(cron:session): session opened for user root by (uid=0)
May  6 16:20:01 a CRON[1878]: pam_unix(cron:session): session closed for user root
May  6 16:21:01 a CRON[1932]: pam_unix(cron:session): session opened for user root by (uid=0)
May  6 16:21:01 a CRON[1932]: pam_unix(cron:session): session closed for user root
May  6 16:22:01 a CRON[1976]: pam_unix(cron:session): session opened for user root by (uid=0)
May  6 16:22:02 a CRON[1976]: pam_unix(cron:session): session closed for user root

Dernière modification par Narumi (Le 24/05/2016, à 17:45)

Hors ligne

#2 Le 06/05/2016, à 22:20

J5012

Re : [résolu] Fail2ban problème ban

tu as lu bien sur ? http://doc.ubuntu-fr.org/fail2ban
on peut avoir ton jail.local complet ?
que donne ?

sudo fail2ban-client status ssh

Hors ligne

#3 Le 15/05/2016, à 11:52

zététix

Re : [résolu] Fail2ban problème ban

Salut,

je te conseille de regarder aussi dans le dossier filter.d. C'est là que sont les regex utilisées pour récupérer l'IP à bannir depuis les logs. Si ça se trouve, la regex est mauvaise ça vaudrait le coup de regarder car ça m'est déjà arrivé !


Aidez-moi à faire connaître mon projet : RaidGHost, un hébergeur (presque :P) gratuit et sans publicité !

Hors ligne

#4 Le 24/05/2016, à 17:44

Narumi

Re : [résolu] Fail2ban problème ban

bonjour,

le soucis a été résolu. je pense qu'il fallait juste relancer le service fail2ban.
le bannissement se fait automatiquement maintenant.


Merci bien pour votre aide.

Hors ligne