Linux – fail2ban on server with LXC Containers

debianfail2baniptableslinuxlxc

The issue is modprobe and iptables don't work inside an LXC Container.

LXC is the userspace control package for Linux Containers, a
lightweight virtual system mechanism sometimes described as “chroot on
steroids”.

iptables error inside the container is:

# iptables -I INPUT -s 122.129.126.194 -j DROP
> iptables v1.4.8: can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.

I am guessing that it can't work because the LXC containers share one kernel, the main server kernel.

How do I do fail2ban in this case.
modprobe and iptables work in the main server so I could install it there and link to the logfiles somehow, my guess?

Any suggestions?

Best Answer

Maybe tcp wrappers works for you. fail2ban can manage /etc/hosts.allow and /etc/hosts.deny files