Jump to content

[F31] fail2ban i systemd - czegoś nie rozumiem


SeeM
 Share

Recommended Posts

Nie mogę zmusić fail2bana tdo banowania IPków.

/var/log/fail2ban.log

2020-02-10 20:14:45,237 fail2ban.actions        [152496]: WARNING [sshd] 218.92.0.210 already banned
2020-02-10 20:14:48,893 fail2ban.filter         [152496]: INFO    [sshd] Found 218.92.0.210 - 2020-02-10 20:14:48
2020-02-10 20:14:53,187 fail2ban.filter         [152496]: INFO    [sshd] Found 218.92.0.210 - 2020-02-10 20:14:52
2020-02-10 20:14:53,249 fail2ban.actions        [152496]: WARNING [sshd] 218.92.0.210 already banned

journalctl -u sshd (218.92.0.210 nadal radośnie próbuje)

lut 10 20:22:07 vps627971.ovh.net sshd[153295]: Failed password for root from 218.92.0.210 port 50601 ssh2

/etc/fail2ban/jail.d/10-sshd.local
 

[sshd]
mode    = aggressive
enabled = true
port    = ssh
#backend = systemd
bantime = 33d
maxretry = 2

Naprawdę nie mam pomysłu. W CentOS 7 to było dla mnie trochę prostsze, bo był tekstowy log /var/log/secure, który fail2ban mógł sobie czytać.

Link to comment
Share on other sites

Dzięki. Nie ma problemu:
 

# fail2ban-client status sshd
Status for the jail: sshd
|- Filter
|  |- Currently failed:    6
|  |- Total failed:    1046
|  `- Journal matches:    _SYSTEMD_UNIT=sshd.service + _COMM=sshd
`- Actions
   |- Currently banned:    9
   |- Total banned:    36
   `- Banned IP list:    218.92.0.210 222.186.175.154 82.51.126.70 80.178.115.146 93.55.209.46 222.186.175.167 49.88.112.62 222.186.173.183 121.229.6.166

W iptables nie ma łąńcucha fai2bana. Tak jakby brakowało mu parametru action i co z tego, że ma Banned IP list, skoro nic z nimi nie robi. Poszukam w tę stronę.

Link to comment
Share on other sites

Być może o to chodzi:

https://www.cyberciti.biz/faq/how-to-protect-ssh-with-fail2ban-on-centos-8/ .

W pliku /etc/fail2ban/jail.local jest linia:

# Call iptables to ban IP addressbanaction = iptables-multiport 

Albo tak jak pisał kolega sunrise - nazwy dostosowane do dystrybucji. Zrestartować usługi, poczekać na bota - sprawdzić logi :D

journalctl -q -b -p 4 -g "IN="

Link to comment
Share on other sites

Dzięki za naprowadzenie, chodziło o parametr action. .Łańcuch Chain f2b-sshd (1 references) świeci się pięknie w iptables. Jedyne, co mi się nie podoba to REJECTowanie tego ruchu. Wolałbym tym botom rozdawać DROPy, no ale mniejsza. Poszukam jutro jak to zrobić. Ważne, że się odczepiły.

Link to comment
Share on other sites

W dniu 10.02.2020 o 21:01, SeeM napisał:

Jedyne, co mi się nie podoba to REJECTowanie tego ruchu. Wolałbym tym botom rozdawać DROPy, no ale mniejsza. Poszukam jutro jak to zrobić. Ważne, że się odczepiły.

Znalazłem. Plik /etc/fail2ban/iptables/action.d/iptables-common;

# Option:  blocktype
# Note:    This is what the action does with rules. This can be any jump target
#          as per the iptables man page (section 8). Common values are DROP
#          REJECT, REJECT --reject-with icmp-port-unreachable
# Values:  STRING
#blocktype = REJECT --reject-with icmp-port-unreachable
blocktype = DROP

Od razu lepiej.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...