LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 08-09-2012, 01:32 PM   #1
Bulletproof
LQ Newbie
 
Registered: Aug 2012
Posts: 5

Rep: Reputation: Disabled
Post Blocking an IP


The following iptable rule blocks an IP:
Quote:
iptables -A INPUT -s 1.2.3.4 -j DROP
I have the following iptable rule to filter out bad packets
Quote:
-A INPUT -p udp -m udp --dport 27015 -m length --length 0:32 -j DROP
I'd like to be able to block IPs that get dropped by the iptable rule above automatically without having to check the logs and do them manually.

Can this be done?

PS: My knowledge in this field is weak.
 
Old 08-09-2012, 01:48 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,679
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
I frankly suggest that you look carefully at Shorewall, which is a very comprehensive open-source tool for building IPTables rules.
 
1 members found this post helpful.
Old 08-09-2012, 01:57 PM   #3
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
Hi,

I don't really know but maybe Fail2ban can be your friend.

good luck
 
Old 08-09-2012, 01:59 PM   #4
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Quote:
Originally Posted by Bulletproof View Post
Can this be done?
Yes, indeedy (I think). But should it?

I'm not totally clear what advantage you hope to gain: you are already dropping the packets that you want to drop, so no advantage there. It could be more efficient (or not), but to know that we'll have to look at the details.

Quote:
Originally Posted by Bulletproof View Post
I'd like to be able to block IPs that get dropped by the iptable rule above automatically without having to check the logs and do them manually.
There are several utilities like fail2ban, denyhosts, etc, that can be used to do blocking based on various failure conditions. If I recall correctly, fail2ban is probably the most versatile, so is probably the best place to start.

The general principle is that fail2ban is a filter, written in python, that looks through log files, and based on the entries in the log files and the conditions that you set, can make new 'block' entries. Now, I'm guessing a bit here, but my guess is that you'd have to have a pretty odd set of conditions for the fail2ban route to use fewer cpu cycles than your existing iptables rule.

So....what do you hope to gain?

(PS: the reply from Lithos came in while I was scribbling.)
 
Old 08-09-2012, 04:44 PM   #5
Bulletproof
LQ Newbie
 
Registered: Aug 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by salasi View Post
Yes, indeedy (I think). But should it?

I'm not totally clear what advantage you hope to gain: you are already dropping the packets that you want to drop, so no advantage there. It could be more efficient (or not), but to know that we'll have to look at the details.
I own a dedicated server used as a gameserver which gets DDoS'd on a daily basis - I have many iptable rules that filter out the obvious IPs used to DDoS (connections are UDP) - now by automatically banning the IP, it will prevent it from being used again to DDoS the server. Dropping the connection doesn't prevent it from being used again to DDoS 5 minutes later.

I will be looking into fail2ban, thanks a bunch to all of you for pointing me in the right direction.

Last edited by Bulletproof; 08-09-2012 at 04:51 PM.
 
Old 08-09-2012, 05:30 PM   #6
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 Bulletproof View Post
I own a dedicated server used as a gameserver
What games exactly? Please be specific about versions.


Quote:
Originally Posted by Bulletproof View Post
which gets DDoS'd on a daily basis (..) Dropping the connection doesn't prevent it from being used again to DDoS 5 minutes later.
Did you ever look for updates for the game binaries you host?
What gaming experiences, logging, anomalies, evidence or whatever else made you think it's DoS attacks?
Did you ever look for specific game anti-DoS measures?
Did you even try traffic analysis based on packet captures (tcpdump / tshark, Wireshark, Snort)?
 
  


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] blocking and non blocking TCP send/recv problem golden_boy615 Programming 5 12-27-2010 03:27 PM
[SOLVED] C - For system calls, is blocking or non-blocking default? golmschenk Programming 4 03-23-2010 10:29 PM
[SOLVED] C - What's the difference between a blocking and a non-blocking call? golmschenk Programming 5 03-06-2010 06:45 PM
help regarding IP blocking Net_Spy Linux - Networking 1 10-12-2008 02:24 PM
IP blocking merlin371 Linux - Networking 2 08-04-2003 10:42 AM

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

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