DietPi v10.6.2: dietpi-banner option 'Fail2ban status' not working with ip/CIDR addresses

Creating a bug report/issue

I have searched the existing open and closed issues

Required Information

  • DietPi version | DietPi v10.6.2
  • Distro version | trixie
  • Kernel version | Linux PC8JM 6.12.101+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.101-1 (2026-08-05) x86_64 GNU/Linux
  • Architecture | amd64 and arm64
  • SBC model | Native PC (x86_64) and RPi 3 Model B (aarch64)
  • Power supply used | 2.5V 1A (RPi 3)
  • SD card used |

Additional Information (if applicable)

  • Software title | (EG: Nextcloud)
  • Was the software title installed freshly or updated/migrated?
  • Can this issue be replicated on a fresh installation of DietPi?
    ← If you sent a “dietpi-bugreport”, please paste the ID here →
  • Bug report ID | echo $G_HW_UUID

Steps to reproduce

  1. Install ssh and fail2ban
  2. Configure fail2ban jail sshd-perma with ‘bantime = -1’
  3. Create ban for a group of ip addresses: fail2ban-client set sshd-perma banip 85.217.140.0/24
  4. Turn on ‘Fail2ban status’ option in dietpi-banner.

Expected behaviour

  • Banner should show ‘Fail2Ban status : 1 IP(s) banned’

Actual behaviour

Fail2Ban status : No IPs banned, check Fail2Ban state

Extra details

  • Banner works correctly if the following line is commented-out in dietpi-banner:
  • #local IP_re=‘^([0-9]+.[0-9]+.[0-9]+.[0-9]+|[0-9a-f:]:[0-9a-f:])$’
  • All of my bans are for /24 or /16 addresses, have not tested banning individual ip addresses.
paste lines of logs or code into such code fences here

Thanks for the report, the regex can not handle CIDR notation, only single IPs.

Can be fixed with this regex
^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(/[0-9]+)?|[0-9a-f:]*:[0-9a-f:]*(/[0-9]+)?)$
But maybe the message needs to be modified to Fail2Ban status : X ban(s), since a ban in CIDR notation would be now considered as one IP.

That works for me, thanks.

Someone replied to your post.

| Jappe
12 August |

  • | - |

Thanks for the report, the regex can not handle CIDR notation, only single IPs.

Can be fixed with this regex
^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(/[0-9]+)?|[0-9a-f:]*:[0-9a-f:]*(/[0-9]+)?)$
But maybe the message needs to be modified to Fail2Ban status : X ban(s), since a ban in CIDR notation would be now considered as one IP.

I created a PR to fix this:

PR merged.

@dpfan1947
Since subnets are (AFAIK) never banned automatically by failed logins, but only manually via fail2ban-client, it would be probably clearer to split things:

  • Counts individual IPs like before, and use only these for highlight/alert message coloring.
  • Count subnet bans separately, and do not let them affect coloring/severity of the message, since it does not say anything about whether there are many unauthorized login attempts or not.
  • The message could then say “X banned IP(s), Y banned subnets”, with the subnet part added only if its number is above zero.

Does this make sense for you, or is it overkill? And is my assumption correct that there are no jails that apply whole subnet bans, or are there native mechanisms for that, like X bans from within a subnet over Y time => ban whole subnet?

You should probably run this by other fail2ban users. This new dietpi-banner option caught my eye and wanted to check it out, but I already have a home-made mechanism for monitoring access attempts and probably won’t use this new option.

Someone mentioned you in a post.

| MichaIng
13 August |

  • | - |

PR merged.

@dpfan1947
Since subnets are (AFAIK) never banned automatically by failed logins, but only manually via fail2ban-client, it would be probably clearer to split things:

  • Counts individual IPs like before, and use only these for highlight/alert message coloring.
  • Count subnet bans separately, and do not let them affect coloring/severity of the message, since it does not say anything about whether there are many unauthorized login attempts or not.
  • The message could then say “X banned IP(s), Y banned subnets”, with the subnet part added only if its number is above zero.

Does this make sense for you, or is it overkill? And is my assumption correct that there are no jails that apply whole subnet bans, or are there native mechanisms for that, like X bans from within a subnet over Y time => ban whole subnet?

The question is basically whether you would find it beneficial, if subnet bans are shown/counted separately, or just like any other ban. And whether you apply subnet mans manually, of have some mechanism which automates this somehow.

Sorry. I will not be using the new dietpi-banner option but yes, it would be beneficial to anyone who manually bans sub-nets and wants to know about new ip bans. By having separate counts, they would know when fail2ban had automatically banned an ip and it was time to manually unban the ip and ban the sub-net instead. I have internet-facing vpn and ssh dietpi systems and currently ban 33 sub-nets. If I banned only ip’s, the count would be much higher.

I am not aware of a fail2ban option that will automatically ban sub-nets. My manual banning of sub-nets is automated hourly… journalctl -u fail2ban, grep, and a python program generate ban sub-net commands that get executed. The commands also append to a file that can be executed one time whenever a new system is installed from scratch. Sometimes, multiple /24 sub-nets are manually merged into one /16 sub-net. Very primitive compared to the stuff you guys write, but this works for me.

Someone replied to your post.

| MichaIng
13 August |

  • | - |

The question is basically whether you would find it beneficial, if subnet bans are shown/counted separately, or just like any other ban. And whether you apply subnet mans manually, of have some mechanism which automates this somehow.