This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
docpublic:systemes:fail2ban_firewalld [2022/06/26 18:31] adminjp [erreur , echecs] |
docpublic:systemes:fail2ban_firewalld [2022/06/27 16:40] (current) adminjp [references] |
||
|---|---|---|---|
| Line 3: | Line 3: | ||
| l' | l' | ||
| - | helas, l' | + | helas, l' |
| Line 15: | Line 15: | ||
| + | ==== configuration ==== | ||
| + | |||
| + | il a fallu adapter les regles par defaut , notament sur les actions firewalld | ||
| + | |||
| + | < | ||
| + | [root@wmu fail2ban]# cat / | ||
| + | # This file is part of the fail2ban-firewalld package to configure the use of | ||
| + | # the firewalld actions as the default actions. | ||
| + | # (along with the empty fail2ban meta-package) if you do not use firewalld | ||
| + | [DEFAULT] | ||
| + | banaction = firewallcmd-rich-rules[actiontype=< | ||
| + | banaction_allports = firewallcmd-rich-rules[actiontype=< | ||
| + | </ | ||
| + | |||
| + | ceci est a associer a / | ||
| + | |||
| + | |||
| + | |||
| + | ==== jail wordpress ==== | ||
| + | |||
| + | toutes les lignes en commentaires representent les divers essais / echec des valeurs proposées par defaut sur plusieurs sites ... | ||
| + | |||
| + | < | ||
| + | [root@wmu ~]# cat / | ||
| + | # https:// | ||
| + | [wordpress] | ||
| + | enabled = true | ||
| + | #banaction = iptables-multiport | ||
| + | #banaction = firewallcmd-new | ||
| + | #banaction = firewallcmd-ipset | ||
| + | #banaction = firewallcmd-rich-rules | ||
| + | port = http,https | ||
| + | filter = wordpress | ||
| + | #action = iptables-multiport[name=wordpress, | ||
| + | #action = %(action_mwl)s | ||
| + | logpath = / | ||
| + | maxretry = 3 | ||
| + | findtime = 120 | ||
| + | bantime = 120 | ||
| + | </ | ||
| + | |||
| + | filtre associé | ||
| + | |||
| + | < | ||
| + | [root@wmu ~]# cat / | ||
| + | [Definition] | ||
| + | failregex = ^< | ||
| + | ^< | ||
| + | ignoreregex = | ||
| + | </ | ||
| + | ==== séparateur de ports ==== | ||
| + | |||
| + | il faut aussi corriger une erreur d' | ||
| + | |||
| + | 1) dans jail.local | ||
| + | |||
| + | < | ||
| + | [root@wmu fail2ban]# vim / | ||
| + | |||
| + | # Ports to be banned | ||
| + | # Usually should be overridden in a particular jail | ||
| + | ##port = 0:65535 | ||
| + | # | ||
| + | port = 0-65535 | ||
| + | </ | ||
| + | |||
| + | 2) mais aussi dans firewallcmd-common.conf | ||
| + | |||
| + | < | ||
| + | [root@wmu fail2ban]# vim / | ||
| + | |||
| + | # JP comment : to - | ||
| + | #port = 1:65535 | ||
| + | port = 1-65535 | ||
| + | </ | ||
| + | ==== resultat operationel ==== | ||
| + | |||
| + | quand cela marche, on doit voir dans les log fail2ban le " | ||
| + | |||
| + | |||
| + | < | ||
| + | [root@wmu fail2ban]# tail -f / | ||
| + | 2022-06-26 20: | ||
| + | 2022-06-26 20: | ||
| + | 2022-06-26 20: | ||
| + | 2022-06-26 20: | ||
| + | 2022-06-26 20: | ||
| + | 2022-06-26 20: | ||
| + | 2022-06-26 20: | ||
| + | 2022-06-26 20: | ||
| + | 2022-06-26 20: | ||
| + | </ | ||
| + | |||
| + | et cela se traduit par une regle correspondante dans le firewall | ||
| + | |||
| + | < | ||
| + | [root@wmut2 fail2ban]# firewall-cmd --list-rich-rules | ||
| + | rule family=" | ||
| + | rule family=" | ||
| + | rule family=" | ||
| + | rule family=" | ||
| + | rule family=" | ||
| + | rule family=" | ||
| + | rule family=" | ||
| + | rule family=" | ||
| + | </ | ||
| + | |||
| + | visible egalement dans les regles natives netfilter/ | ||
| + | |||
| + | < | ||
| + | chaichain filter_IN_public_deny { | ||
| + | ip saddr 143.244.147.196 tcp dport 443 ct state { new, untracked } reject | ||
| + | ip saddr 148.72.244.104 tcp dport 443 ct state { new, untracked } reject | ||
| + | ip saddr 123.25.115.29 tcp dport 443 ct state { new, untracked } reject | ||
| + | </ | ||
| + | |||
| + | |||
| + | car c'est bien nft qui tourne au final, cf : | ||
| + | |||
| + | < | ||
| + | [root@wmu fail2ban]# grep -i ' | ||
| + | # FirewallBackend | ||
| + | FirewallBackend=nftables | ||
| + | </ | ||
| + | |||
| + | |||
| + | etat du jail wordpress | ||
| + | |||
| + | < | ||
| + | [root@wmu ~]# fail2ban-client status wordpress | ||
| + | Status for the jail: wordpress | ||
| + | |- Filter | ||
| + | | |- Currently failed: 3 | ||
| + | | |- Total failed: | ||
| + | | `- File list: | ||
| + | `- Actions | ||
| + | |- Currently banned: 7 | ||
| + | |- Total banned: 410 | ||
| + | `- Banned IP list: | ||
| + | </ | ||
| ===== erreur , echecs ==== | ===== erreur , echecs ==== | ||
| Line 64: | Line 204: | ||
| - https:// | - https:// | ||
| - https:// | - https:// | ||
| + | - https:// | ||
| + | - https:// | ||
| + | - https:// | ||
| + | - https:// | ||
| + | - https:// | ||
| + | - https:// | ||
| - https:// | - https:// | ||
| + | - https:// | ||
| + | - https:// | ||
| + | - https:// | ||
| + | - https:// | ||
| + | - https:// | ||