Fail2Ban command snippets
Copy-paste-ready fail2ban-client commands for checking status, banning IPs, and testing filters.
- Fail2Ban command snippets
- List All Active Fail2Ban Jails
- Check Banned IPs for a Specific Fail2Ban Jail
- Manually Ban an IP in Fail2Ban
- Manually Unban an IP in Fail2Ban
- Test a Fail2Ban Filter Against a Log File
- Test a Fail2Ban Filter Against the systemd Journal
- Reload Fail2Ban Configuration Without Restarting
- Show Fail2Ban Version and Configuration Summary
- View the Fail2Ban Log File
Fail2Ban command snippets
Copy-paste-ready fail2ban-client commands for checking status, banning IPs, and testing filters.
List All Active Fail2Ban Jails
fail2ban-client lists every enabled jail:
sudo fail2ban-client statusCheck Banned IPs for a Specific Fail2Ban Jail
fail2ban-client shows the number of bans and the list of currently banned IPs:
sudo fail2ban-client status sshdManually Ban an IP in Fail2Ban
fail2ban-client adds a ban for a specific IP in a jail:
sudo fail2ban-client set sshd banip 203.0.113.45Manually Unban an IP in Fail2Ban
fail2ban-client removes a ban for a specific IP:
sudo fail2ban-client set sshd unbanip 203.0.113.45Test a Fail2Ban Filter Against a Log File
fail2ban-regex reports how many lines match the filter's regex:
sudo fail2ban-regex /var/log/auth.log /etc/fail2ban/filter.d/sshd.confTest a Fail2Ban Filter Against the systemd Journal
fail2ban-regex reads from the journal when given
systemd-journal as the log source:
sudo fail2ban-regex systemd-journal /etc/fail2ban/filter.d/sshd.confReload Fail2Ban Configuration Without Restarting
fail2ban-client reloads all jails and filters:
sudo fail2ban-client reloadShow Fail2Ban Version and Configuration Summary
fail2ban-client displays the server version:
sudo fail2ban-client versionView the Fail2Ban Log File
The Fail2Ban log records all ban and unban actions:
sudo tail -50 /var/log/fail2ban.log