大网数据广告活动
服务器运维问答

fail2ban restarts immediately after stopping

· 52CE 我爱测

It seems like fail2ban is restarted immediately after calling fail2ban-client stop . Here's a part of the log file 2016-08-29 22:51:42,164 fail2ban.jail [2886]: INFO Jail 'apache-overflows' stopped 2016-08-29 22:51:42,168 fail2ba…

问题原文

原帖链接 · user2224350 · CC BY-SA 3.0

It seems like fail2ban is restarted immediately after calling fail2ban-client stop. Here's a part of the log file

2016-08-29 22:51:42,164 fail2ban.jail [2886]: INFO Jail 'apache-overflows' stopped

2016-08-29 22:51:42,168 fail2ban.server [2886]: INFO Exiting Fail2ban

2016-08-29 22:51:43,300 fail2ban.jail [3235]: INFO Jail 'apache-overflows' started

Also fail2ban-client status returns

Status
|- Number of jail:  11
`- Jail list:   apache-auth,...

已采纳解答

原帖链接 · Ryan Babchishin · CC BY-SA 3.0

fail2ban is probably being managed by systemd

On my Ubuntu 16.04 system, the fail2ban service file looks like this:

# /lib/systemd/system/fail2ban.service
[Unit]
Description=Fail2Ban Service
Documentation=man:fail2ban(1)
After=network.target iptables.service firewalld.service

[Service]
Type=forking
ExecStart=/usr/bin/fail2ban-client -x start
ExecStop=/usr/bin/fail2ban-client stop
ExecReload=/usr/bin/fail2ban-client reload
PIDFile=/var/run/fail2ban/fail2ban.pid
Restart=always

[Install]
WantedBy=multi-user.target

According to the documentation Restart=always means this:

If set to always, the service will be restarted regardless of whether it exited cleanly or not, got terminated abnormally by a signal, or hit a timeout.

So you're fail2ban service is automatically restarting when you stop it.

If you want to stop it you'll need to use systemctl

systemctl stop fail2ban

You can start it again with

systemctl start fail2ban

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-08-29)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。