LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 02-14-2014, 05:15 PM   #1
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Rep: Reputation: 1
How to block an ip number


I am using Centos 6 and iptables-1.4.7-9.el6.i686

I want to block regular attackers through the iptables.
This is what I have used, but it doesn't seem top stop the attacks:
Code:
-A RH-Firewall-1-INPUT -i eth0 -s xxx.xxx.xxx.xxx -j DROP
btw, I am using fail2ban.

Any advise will be very welcome.

Thanks,
 
Old 02-14-2014, 07:52 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
Quote:
Originally Posted by countrydj View Post
I want to block regular attackers through the iptables. (..) I am using fail2ban.
Fail2ban already contains default configuration for blocking through the firewall. So unless you want change to a different table (raw versus filter) or better performing method (ipset instead of iptables) you don't need to fiddle with iptables rules.


Quote:
Originally Posted by countrydj View Post
it doesn't seem top stop the attacks
You haven't told us what kind of attacks these are, if fail2ban was configured to catch these, what fail2ban logs about attacks and if rules get added to your iptables rule set.
 
Old 02-18-2014, 08:17 AM   #3
Linux_Kidd
Member
 
Registered: Jan 2006
Location: USA
Posts: 737

Rep: Reputation: 78
can F2B catch CIFS buffer overflow attack? or an attack that is ingress targeting Flash player?
different tools for different purposes, F2B is just one tool with limitations, etc.
define your requirements for protecting the system, then find the right tool(s).
 
Old 02-18-2014, 12:46 PM   #4
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Hi Guys...
Thanks for taking the time to reply to me.
I have now moved the iptables rule to the top and all the intrusions have stopped.

Problem solved.

Thanks again for your replies.
 
Old 02-19-2014, 12:34 PM   #5
Linux_Kidd
Member
 
Registered: Jan 2006
Location: USA
Posts: 737

Rep: Reputation: 78
Quote:
Originally Posted by countrydj View Post
Hi Guys...
Thanks for taking the time to reply to me.
I have now moved the iptables rule to the top and all the intrusions have stopped.

Problem solved.

Thanks again for your replies.
i am curious to know how you think iptables is stopping "intrusions". if the src IP changes are you still ok?
 
Old 02-19-2014, 02:13 PM   #6
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Hi Linux_Kidd ...
Thanks for your interest.
Quote:
i am curious to know how you think iptables is stopping "intrusions". if the src IP changes are you still ok?
No. I am not covered.
However, I do have fail2ban running, which stops intrusions.
The reason that I wanted to ban a particular ip number, is that it was persistant in it's attempts. Each time it was banned I got an email telling me. After a couple of weeks of getting a stack of emails, I decided that I wanted to ban the ip number before it got to fail2ban.
I was concerned that if this ip number was persistant enough, it may eventually crack my security. Probably not, but I wanted to be sure.
Dropping it in iptables did that. I don't have any trouble now.
Hope this explains it for you...
 
Old 02-26-2014, 02:02 PM   #7
Linux_Kidd
Member
 
Registered: Jan 2006
Location: USA
Posts: 737

Rep: Reputation: 78
if say attacker has a bunch of bots and each bot is executing different piece of the attack (like brute force ssh from a-c on bot1, and d-f on bot2, etc etc), fail2ban is not a 100% useful tool in protecting against this type of attack.

the Q from unSpawn was never answered,,,,,, what type of attacks are you talking about?
 
Old 02-26-2014, 02:24 PM   #8
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Quote:
the Q from unSpawn was never answered,,,,,, what type of attacks are you talking about?
I didn't look at the logs.
I get an email every time an ip gets banned by fail2ban, and one particular ip number was showing up every time.
When I banned that ip number in iptables, I didn't get any more bans by fail2ban.
Maybe it was the same attacker using different bots, and gave up.
All I was interested in was stopping any attacks being picked up by fail2ban. And that has been achieved.
Hope this explains it better.
 
Old 02-26-2014, 02:42 PM   #9
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
bantime  = 31556926 ; 1 year in seconds
in your /etc/fail2ban/jail.local stanza for each, is what I use.
 
Old 02-26-2014, 03:29 PM   #10
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Quote:
in your /etc/fail2ban/jail.local stanza for each, is what I use
I don't have a jail.local. I only have jail.conf.

Can you please enlighten me ???
 
Old 02-26-2014, 05:39 PM   #11
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by countrydj View Post
I don't have a jail.local. I only have jail.conf.

Can you please enlighten me ???
https://www.linuxquestions.org/quest...istence-35932/
 
Old 02-27-2014, 03:50 AM   #12
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Thank you.
I will study it more and better when I return from holiday.
 
Old 02-27-2014, 07:18 AM   #13
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
You're very welcome.

Basically, the process is this.
Copy the jail.conf to preserve your settings in case of an update/upgrade to fail2ban.
Any .conf files installed (and even modified) after installation will be lost if/when f2b is upgraded.
It's not too late to copy it now (post install or modify) using
Code:
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
 
1 members found this post helpful.
Old 02-27-2014, 10:45 AM   #14
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Thank you habitual..

I have done
Code:
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
I will be going away for a week tomorrow morning, so I will take a look at the link that you sent when I get back.
 
Old 02-27-2014, 10:48 AM   #15
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
I'll be "here".

subscribed with interest...
 
  


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
Block massive number of ips, JoeJoe Linux - Software 5 07-04-2010 03:26 AM
How to get a block number sunnyboy Programming 1 08-09-2009 09:26 PM
why sector number not match block number? bitzsk Linux - Kernel 1 06-09-2009 05:32 AM
why block number changed after change of file? bitzsk Linux - Kernel 2 06-05-2009 07:10 AM
Bad magic number in super-block kubokubik Linux - Newbie 4 01-26-2005 10:52 AM

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

All times are GMT -5. The time now is 07:13 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