3

Where the problems started:

First i tried to install fail2ban from the ISPmanager UI, the fail2ban was installed but i got a error related to the package coremanager-pkg-fail2ban, and the fail2ban was not working so i tried to uninstalled it using the ISPmanager UI and using the command apt-get remove coremanager-pkg-fail2ban but it said that there's no package with this name, and this error still remains: error

I did apt-get remove fail2ban and apt-get purge auto-remove fail2ban after this i reinstalled fail2ban using the command apt-get install fail2ban and i was getting this error: failed to validate path /var/run/fail2ban too many levels of symbolic links. I searched a bit and i found this answear https://serverfault.com/a/949286/521284, what did solved my problem with the fail2ban, and now fail2ban is running on my server:

root# systemctl status fail2ban 
fail2ban.service - Fail2Ban Service
    Loaded: loaded (/lib/systemd/system/fail2ban.service; enabled; vendor preset: enabled)
    Active: active (running) since Mon 2019-04-29 15:44:15 EDT; 18min ago
    Docs: man:fail2ban(1)
    Process: 293 ExecStart=/usr/bin/fail2ban-client -x start (code=exited, status=0/SUCCESS)
    Main PID: 411 (fail2ban-server)
    CGroup: /system.slice/fail2ban.service
           └─411 /usr/bin/python3 /usr/bin/fail2ban-server -s /var/run/fail2ban/fail2ban.sock -p /var/run/fail2ban/fail2ban.pid -x -b

Apr 29 15:44:13 testdomain systemd[1]: Starting Fail2Ban Service...
Apr 29 15:44:14 testdomain fail2ban-client[293]: 2019-04-29 15:44:14,540 fail2ban.server [374]: INFO Starting Fail2ban v0.9.3
Apr 29 15:44:14 testdomain fail2ban-client[293]: 2019-04-29 15:44:14,541 fail2ban.server [374]: INFO Starting in daemon mode
Apr 29 15:44:15 testdomain systemd[1]: Started Fail2Ban Service.

But when i do ufw enable i get this error and my OS crashes and i need to restart the OS:

root# ufw enable
ERROR: problem running ufw-init
modprobe: ERROR: ../libkmod/libkmod.c:514 lookup_builtin_file() could not open builtin file '/lib/modules/2.6.32-042stab127.2/modules.builtin.bin'
modprobe: FATAL: Module nf_conntrack_ftp not found in directory /lib/modules/2.6.32-042stab127.2
modprobe: ERROR: ../libkmod/libkmod.c:514 lookup_builtin_file() could not open builtin file '/lib/modules/2.6.32-042stab127.2/modules.builtin.bin'
modprobe: FATAL: Module nf_nat_ftp not found in directory /lib/modules/2.6.32-042stab127.2
modprobe: ERROR: ../libkmod/libkmod.c:514 lookup_builtin_file() could not open builtin file '/lib/modules/2.6.32-042stab127.2/modules.builtin.bin'
modprobe: FATAL: Module nf_conntrack_netbios_ns not found in directory /lib/modules/2.6.32-042stab127.2
iptables-restore: line 4 failed
iptables-restore: line 77 failed
iptables-restore: line 30 failed
ip6tables-restore: line 4 failed
ip6tables-restore: line 138 failed
ip6tables-restore: line 30 failed
sysctl: permission denied on key 'net.ipv4.tcp_sack'

Problem running '/etc/ufw/before.rules'
Problem running '/etc/ufw/user.rules'
Problem running '/etc/ufw/before6.rules'
Problem running '/etc/ufw/user6.rules'

I'm tring to solve this problem with the ufw, could someone help? My ubuntu version is 16.04. And i'm using Apache2

mario
  • 145
  • 1
  • 8
  • You host uses a very old OpenVZ and not much modern will run on it. If you have modern needs, you’ll have to switch hosts. – John Keates Apr 30 '19 at 15:33

1 Answers1

3

Your "virtual machine" is not a true virtual machine, but an OpenVZ "container" (and not a modern container, but an ancient pre-LXC container). OpenVZ does not permit containers to load kernel modules, which you have to do in order to use the firewall features you are trying to use. Further, the 2.6.32 based kernel which they supply is too old to use many modern Linux features anyway. It was released in 2009!

To solve the problem, get a new VPS from another provider, which does not use OpenVZ or its commercial variant Virtuozzo.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • I have searched a lot about how to secure a VPS, most articles/forums/tutorials talks about `fail2ban` and `ufw` and they mention `SSH`, so i think that these firewalls is for people that use `SSH` (i'm not sure), right? I don't use `SSH` and i have disabled it. There's another firewall called `CSF` that i found, but this one also did not worked in my VPS. I tried to install `ModSecurity (WAF)` and this one worked. – mario Apr 30 '19 at 01:44
  • I will use `ModSecurity` and `CloudFlare (Free account)`, do you think it's good enough? If not, what do i have to worry about, botnets, DDoS, brute force? My admin passwords is really strong, so i don't think brute force would be a problem, at least for the admin panel. Do you have any recommendation? Change my VPS provider is not a option at momment. – mario Apr 30 '19 at 01:45
  • I would not ever buy an OpenVZ based VPS at all. It might be good enough for now, but you should make plans to change as soon as possible. – Michael Hampton Apr 30 '19 at 01:47