Précision logs iptables

Bonjour à tous,

la commande iptables -L est polluée par un message imprécis et redondant par centaines:

iptables -L -v
    0     0 RETURN     all  --  any    any     anywhere             anywhere            
...

Comment obtenir des précisions sur ce message et comment l’éliminer ?

Ce n’est pas un message, c’est une règle. Quel rapport avec les logs ?

Ce que tu indiques n’est pas un message, c’est une des règles restituées par la commande iptables concernant la cible filter.
Ce sont des règles que >tu< as insèré toi même, connaissant ton install.

La question n’a pas de sens, vu que ce ne sont pas des messages.
Sinon, trouves dans ton script de parefeu ce qui ajoute ces règles, désactives le, et elles disparaîtront.

Ou bien qu’un programme qui utilise iptables a insérées. On peut rechercher quels paquets installés ont une dépendance avec iptables pour avoir des pistes.

apt-cache --installed rdepends iptables

Un petit extrait des règles autour de celles-ci affichées par iptables-save pourrait aussi apporter des informations.

Je pense que ce sont des règles établies par fail2ban suite à des attaques mais je ne trouve pas comment avoir plus de détail sur ce qui les a déclenchées

Il faut probablement chercher dans les logs de fail2ban.

J’analyse les logs de fail2ban en effet mais j’aurais voulu savoir comment vous interprétiez la ligne

0     0 RETURN     all  --  any    any     anywhere 

S’il s’agit d’une règle générée par Fail2ban je ne comprends pas ni sa répétition des centaines de fois ni comment déterminer à quelle(s) IP(s) elle correspondent. Autrement dit, comment faire le lien entre le listing IPTABLES et les logs FAIL2BAN ?

On interprète comme la page de man de iptables :

RETURN means stop traversing
this chain and resume at the next rule in the previous (calling) chain. If the end of a built-in chain is reached
or a rule in a built-in chain with target RETURN is matched, the target specified by the chain policy determines
the fate of the packet.

Cette règle ne peut pas s’interpréter seule mais dans dans le contexte du jeu de règles.
Ces règles sont-elles toutes dans la même chaîne ou bien chacune dans une chaîne différente ?
On peut voir un extrait significatif de la sortie de iptables-save ?

# iptables-save
...
-A f2b-postfix-sasl -j RETURN (répété des centaines de fois, au delà des capacités du terminal, comme le messae à l'origine de ce post)
-A f2b-sshd -s 106.13.105.77/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 119.29.194.198/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 212.64.44.246/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 222.186.15.204/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 222.186.175.150/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 200.60.91.42/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 58.210.96.156/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 148.70.11.98/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 153.3.232.177/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 106.13.150.14/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 51.83.78.109/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 222.186.180.8/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 95.174.219.101/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 94.23.212.137/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 192.227.210.138/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 222.186.42.241/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 47.74.150.153/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 222.186.175.167/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 14.21.7.162/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 175.207.219.185/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 213.251.41.52/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 129.226.129.191/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 106.54.94.95/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 158.69.63.244/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 118.163.181.157/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -s 222.186.175.182/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-sshd -j RETURN
-A f2b-postfix -j RETURN
-A f2b-pureftpd -j RETURN
-A f2b-recidive -s 106.13.105.77/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 58.210.96.156/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 153.3.232.177/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 106.13.150.14/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 192.227.210.138/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 222.186.175.167/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 14.21.7.162/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 80.211.133.238/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 222.186.175.6/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 115.238.236.74/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 185.9.3.48/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 167.99.203.202/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 133.130.107.85/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 198.100.146.98/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 190.85.108.186/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 91.215.244.12/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 112.85.42.89/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 61.175.121.76/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 139.217.102.155/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 222.186.175.147/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 34.73.39.215/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 139.155.44.100/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 162.243.10.64/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 165.227.112.164/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 186.209.74.108/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 51.38.57.78/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 200.29.108.214/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 222.186.175.140/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 78.128.113.116/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 140.143.98.35/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 89.216.47.154/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 222.186.175.202/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 217.182.74.125/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 167.71.91.228/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 213.32.67.160/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 200.108.143.6/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 51.68.44.158/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 139.59.4.224/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 103.76.21.181/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 27.50.162.82/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 92.222.77.175/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 41.207.182.133/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 106.13.81.18/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 112.85.42.185/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 103.36.84.100/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 141.98.80.81/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 222.186.175.220/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 222.186.180.6/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 159.224.66.240/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 129.213.18.41/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 139.59.94.192/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 222.186.173.183/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 222.186.180.223/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 45.82.153.37/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 222.186.173.142/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 121.162.131.223/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 92.222.216.81/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 222.186.42.4/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 123.206.74.50/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 118.24.135.240/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 171.244.51.114/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 89.248.168.221/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 144.217.15.161/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 139.99.219.208/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 123.207.86.68/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 194.84.17.5/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 170.150.155.102/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 185.17.41.198/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 222.186.180.9/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 110.80.17.26/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 222.186.175.161/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 52.172.138.31/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 188.254.0.197/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 13.94.57.155/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 139.217.103.62/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 106.12.94.65/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 129.211.27.10/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 206.189.162.87/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 175.124.43.123/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 81.74.229.246/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 157.230.91.45/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 187.122.102.4/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 130.61.28.159/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 168.243.91.19/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 62.48.150.175/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 197.248.16.118/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 222.242.223.75/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 106.13.200.7/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 103.233.153.146/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 129.28.191.55/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -s 92.63.194.121/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-recidive -j RETURN
-A f2b-roundcube-auth -j RETURN
COMMIT
# Completed on Mon Oct  7 21:22:51 2019
# Generated by xtables-save v1.8.2 on Mon Oct  7 21:22:51 2019
*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:INPUT ACCEPT [0:0]
COMMIT
# Completed on Mon Oct  7 21:22:51 2019
# Warning: iptables-legacy tables present, use iptables-legacy-save to see them

Si je comprends bien il y a un grand nombre de règles RETURN dans la chaîne f2b-postfix-sasl, alors qu’il n’y en a qu’une en fin de chaîne dans les autres chaînes (ce dont je ne vois pas l’utilité, RETURN étant déjà la politique par défaut d’une chaîne utilisateur). Il faudrait donc examiner la configuration de fail2ban pour postfix-sasl.

Cela semble confirmer le problème de configuration évoqué dans ton autre fil de discussion

Effectivement ce problème a été résolu en corrigeant la conf fail2ban. Voir l’autre fil de discussion.
Merci à vous