LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 09-17-2013, 08:54 AM   #1
ScottG
LQ Newbie
 
Registered: Sep 2013
Posts: 16

Rep: Reputation: Disabled
How to find out how many current fail2ban bans I have?


Hi

I would like to know how to tell how many current bans a fail2ban jail has? I know I could use > status <jail> but this returns all the banned IP addresses too - and I have thousands :-( Is there a way to show number of bans without listing IPs?

Previously I was using iptables to ban so I was able to use service iptables status | wc -l to see how many entries there were but after 24,000 bans (in less than 8 hours) the server started having memory issues. Therefore, on advise from this forum, I have changed over ipset and it is working fine (so far) but I cannot use the above command to view the number of bans.

Thanks very much for reading and for any help.

Scott

Last edited by ScottG; 09-17-2013 at 11:24 AM. Reason: added fail2ban to main text
 
Old 09-17-2013, 02:05 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
The number of `ipset -S YOUR_IPSET_SET_NAME|wc -l` minus two for the header and minus two footer.
 
1 members found this post helpful.
Old 09-17-2013, 03:33 PM   #3
ScottG
LQ Newbie
 
Registered: Sep 2013
Posts: 16

Original Poster
Rep: Reputation: Disabled
Thumbs up

Thanks - just what I was looking for
 
Old 09-17-2013, 04:57 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
NP. BTW this could be a way to list all sets and their use:
Code:
ipset --list | awk '/^Name:/ {print $2}'|while read SETNAME; do
 COUNT=$(ipset --list "${SETNAME}"|grep -v ':' -c); echo "${SETNAME}: ${COUNT}"
done
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Fail2Ban or Similar build for slackware 14-Current cooholio Slackware 13 06-26-2013 05:24 PM
LXer: Microsoft Bans Its Own License LXer Syndicated Linux News 0 02-18-2011 10:40 AM
fail2ban questions - How to find banned IP addresses vonedaddy Linux - Security 3 01-11-2008 04:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 07:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration