Can't start fail2ban

Hello, when I run the following PHP script:

root@rome01:~# /usr/bin/php-cli /etc/fail2ban/cron2ban.php

Script file:

root@rome01:~# cat /etc/fail2ban/cron2ban.php 
#!/usr/bin/php
<?php
// This must be added to Cronjob to run each 1 minute
//Check the PHP path with the command "which php" in terminal
// sudo crontab -e
// */1 * * * * /usr/bin/php /home/domoticz/fail2ban-central/cron2ban.php
// phpconfig.php will have database configuration settings
require_once((dirname(__FILE__))."/config.php");
// file with only a line, containing the last id banned the path is present in the config file.
$lastban = "";
if (file_exists ($lastbanfile)) {
	$lastban = file_get_contents($lastbanfile);
	}
if ($lastban == "") { $lastban = 0; }
// select only hosts banned after last check
$sql = "SELECT * FROM `".$tablename."` WHERE `id` > ".$lastban;
//echo $sql;
$result = mysqli_query($link,$sql) or die('Query failed: ' . mysqli_error($link));
mysqli_close($link);
if (mysqli_num_rows($result) >= 1) {
	while ($row = mysqli_fetch_array($result)) {
        //
        $id = $row['id'];
        $ip = $row['ip'];
    exec("fail2ban-client set $jail banip $ip");
}
// $id contains the last banned host, add it to the config file
file_put_contents($lastbanfile, $id);
	}

I get the following error message:

PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqlnd.so' (tried: /usr/lib/php8/mysqlnd.so (Error relocating /usr/lib/php8/mysqlnd.so: BIO_new_mem_buf: symbol not found), /usr/lib/php8/mysqlnd.so.so (Error loading shared library /usr/lib/php8/mysqlnd.so.so: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqli.so' (tried: /usr/lib/php8/mysqli.so (Error relocating /usr/lib/php8/mysqli.so: mysqlnd_poll: symbol not found), /usr/lib/php8/mysqli.so.so (Error loading shared library /usr/lib/php8/mysqli.so.so: No such file or directory)) in Unknown on line 0

Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /etc/fail2ban/config.php:26
Stack trace:
#0 /etc/fail2ban/cron2ban.php(11): require_once()
#1 {main}
  thrown in /etc/fail2ban/config.php on line 26

How can I fix the error?

Greetings from Stefan Harbich

Where do I have to deactivate this?

That can't be the solution. Because by default all jails are disabled in jail.conf.

f2b starts just fine with the default settings.

2024-05-15 20:04:51,033 fail2ban.server         [25400]: INFO    --------------------------------------------------
2024-05-15 20:04:51,034 fail2ban.server         [25400]: INFO    Starting Fail2ban v0.11.2
2024-05-15 20:04:51,036 fail2ban.observer       [25400]: INFO    Observer start...
2024-05-15 20:04:51,052 fail2ban.database       [25400]: INFO    Connected to fail2ban persistent database '/var/lib/fail2ban/fail2ban.sqlite3'
2024-05-15 20:04:51,060 fail2ban.database       [25400]: WARNING New database created. Version '4'

/etc/fail2ban/cron2ban.php doesn't exist in the default package,
and I guess you skipped the prerequisites at https://github.com/mydomo/fail2ban-central ?

why someone would try to use an 6 y.o addon, is beyond me.

My fail2ban service also starts without any problems. Status is okay. I suspect the problem here:

(Error loading shared library /usr/lib/php8/mysqlnd.so.so: No such file or directory))

I suspect the problem here:
The file has the ending "...mysqlnd.so.so" twice. Why? so.so???

Ask the guy who wrote the code, 6 years ago.

This is not an Openwrt issue, it's not even a fail2ban issue.

It worked. After a newer build, it was no longer possible. I'll reinstall the old firmware to check if it works again. I guess that's something wrong in the PHP code.

It works with the old firmware. So it's because of the new build. What is the best way to compare the old build with the new one?

I was able to solve the problem. When building the new image I built two additional php packages.

  • php8-mod-openssl
  • php8-mod-ldap
    These two modules cause the error. When I removed both packages from the build it worked.