Ielaušanās novēršana ar fail2ban
Saturs
Uzstādīšana
Uzstāda fail2ban servisu ar komandu:
sudo su
apt install fail2banKā root lietotājs izveido lokālās kopijas iestatījumu failiem, kuros var veikt labojumus:
cd /etc/fail2ban/
cp jail.conf jail.local
cp fail2ban.conf fail2ban.localVeic nepieciešamos pielāgojumus jail.local, piemēram:
ignoreip = 127.0.0.1/8 ::1 172.31.4.49/32 52.58.11.108/32 2a05:d014:4ec:de01:ee0f:1bf4:6331:608d/128 94.100.8.131/32 85.254.75.0/24
bantime = 5m
bantime.increment = true
bantime.rndtime = 5m
bantime.maxtime = 100d
bantime.factor = 2
bantime.formula = ban.Time * math.exp(float(ban.Count+1)*banFactor)/math.exp(1*banFactor)
bantime.overalljails = true
findtime = 1dVeic nepieciešamos pielāgojumus fail2ban.local, piemēram:
dbpurgeage = 30d
Darbības
Kopējā statusa pārbaude
sudo fail2ban-client statusKonkrēta "cietuma" pārbaude:
fail2ban-client status <jail>"Cietuma" ignorētās adreses:
fail2ban-client get sshd ignoreipParādīt liegšanas darbības
fail2ban-client get <jail> actionsParādīt liegšanas laiku
sudo fail2ban-client get <jail> bantimeAdreses izņemšana no liegto saraksta:
fail2ban-client set <jail> unbanip <IP>
Apache kļūdu apstrāde
- Saglabā failu , piemēram, /home/bin/ban-abusers.sh
- Pielāgo nosacījumus (regulārās izteiksmes) žurnālu failu meklēšanai un rindu atlasei
Padara failu izpildāmu root lietotājam:
chown root:root ban-abusers.sh
chmod 750 ban-abusers.shIeplāno skripta izpildi root lietotājam katras 10 minūtes:
crontab -eun pievieno rindas:
*/10 * * * * /home/bin/ban-abusers.shun saglabā iestatījumus
VNC un RDP iestatījumi
Lejuplādē un attiecīgās /etc/fail2ban/ vietās ievieto failus
Lai fail2ban serviss palaistos, ir nepcieciešami iestatījumos norādītie faili!
Ja nepieciešams, skatīt Regexp for fail2ban (for xrdp.log)
Papildu informācija
- Using Fail2ban to Secure Your Server
- Example of fail2ban configuration to ban servers spamming my postfix server?
- How to use Fail2ban for securing Apache web server from 404 attacks?
- How To Protect an Apache Server with Fail2Ban on Ubuntu 14.04
- How to configure fail2ban to protect Apache HTTP server
Tags
Serveris
Linux
Created by Valdis Vītoliņš on 2026-04-01 13:31
Last modified by Valdis Vītoliņš on 2026-10-22 11:23
Created by Valdis Vītoliņš on 2026-04-01 13:31
Last modified by Valdis Vītoliņš on 2026-10-22 11:23


