#996899 Wrong myip expression in action.d/dshield.conf and action.d/mynetwatchman.conf for Debian Bullseye

#996899#5
Date:
2021-10-20 12:46:55 UTC
From:
To:
Dear Maintainer,

After Updating to debian bullseye and changing the legacy network
interface names to the new ones in /etc/fail2ban/action.d/dshield.conf
and /etc/fail2ban/action.d/mynetwatchman.conf the expression "myip = `ip
-4 addr show dev eth0 | grep inet | head -n 1 | sed -r 's/.*inet 
([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*/\1/'`" would be
incorrect.

In this specific case the new interface name would be "enp1s0". Hence
the correct expresion would be "myip = `ip -4 addr show dev enp1s0 |
grep inet | head -n 1 | sed -r 's/.*inet
([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*/\1/'`"

I suggest that the expression is changed to something that checks if
legacy network interface names are used or new ones.
Somehting like: DEV="$(ls -1 /sys/class/net | grep -v lo | sort -n |
head -n 1)" or similiar.

I am using Debian 5.10.70-1 (2021-09-30) x86_64 GNU/Linux, kernel
5.10.0-9-amd64