[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

Using an effective iptables blacklist

Asked by forrie in IP Tables/IP Chains, Unix Networking

Tags: iptables linux security firewall

I've migrated my mail and web services from a FreeBSD/PF environment to Linux/iptables (CentOS 5.3).  

Being relatively new to iptables, I sought a pre-configured setup to facilitate a quicker rollout - I found a script called "ipkungfu" (which is no longer being developed).   This post is not about that script, so much as it is a question about how to utilize iptables effectively.

Along with my configuration I have a few tables of IPs (mostly /24's) from my PF configuration, tables of:  abuse, spammers and geoip.   The abuse table are IPs that I never, ever want touching any services on my system.  Spammers, blocked from port 25.  Geoip, is generally no access as well.

Iptables has three basic initial chains:

INPUT
FORWARD
OUTPUT

I set up a custom script that would do a for-next loop through the IPs and do something like this:

$iptables -I abuse -s $i -j DROP

I found this isn't working.  I also found that loading large IP lists into iptables is painfully slow (it was lightning fast under FreeBSD/PF).

One particularly annoying host from netsync.net had been slamming my system repeatedly.  The IP was in the DROP directive, but it was getting through anyway.  This, I thought, was due to the fact that some of my services are FORWARDed to an internal host and thus perhaps bypassing something.   I was able to block this host by issuing this command:

# iptables -A FORWARD -s 208.20.34.161 -j DROP
# iptables -A FORWARD -s 208.20.34.150 -j DROP

So my predicament is in correctly understanding how to effectively block these large lists of IPs.  Some of them are BOTNETs some of them are /24's that are dynamic that have shown other patterns of abuse.  Because my server is private, I don't need to be concerned about inadvertently blocking someone.

First, is there a more effective way to block these lists in iptables?  Is there a more efficient way to load these large lists of IPs into the chain(s)?  At this point, it actually causes my system boot time to lag significantly.

Where is the best place to block these IPs in the chains and why doesn't just blocking it in the INPUT chain work.  Or did I configure the DROP incorrectly?

Thanks!
1:
2:
3:
4:
5:
6:
7:
iptables -N abuse
 
 
        for i in `cat $dir/abuse | egrep -hv "^#|$^"`
        do
                $iptables -I abuse -s $i -j DROP
        done
[+][-]09/09/09 11:58 PM, ID: 25297847Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: IP Tables/IP Chains, Unix Networking
Tags: iptables linux security firewall
Sign Up Now!
Solution Provided By: Blaz
Participating Experts: 1
Solution Grade: A
 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625