112c8 [IPFW] Practical limit on the number if IPFW rules - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Server & Networking > Firewalls

Firewalls IPFW, PF, IPF (but not limited) related discussion

Reply
 
Thread Tools Display Modes
  #1  
Old July 19th, 2012, 08:56
trwzm trwzm is offline
Junior Member
 
Join Date: Jul 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Practical limit on the number if IPFW rules

I'm running a small web and email server on 32-bit FreeBSD version 9.0.
I just moved my email domains from another internet service provider, who had really great spam blocking. Now I'm seeing a lot of spam traffic coming from outside the United States. My first reaction is to block everything outside of the U.S., but that seems to be the most rule intensive, so I found a list of the U.S. IP addresses, which would require 42,445 rules. Would that size rule set be too much? If, so, does anyone have a better way?

Thanks,

-Rusty
Reply With Quote
  #2  
Old July 19th, 2012, 09:42
SirDice's Avatar
SirDice SirDice is offline
Moderator
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 13,725
Thanks: 47
Thanked 2,023 Times in 1,862 Posts
Default

Blocking on IP addresses is rather a futile business. Use a spamfilter.

mail/p5-Mail-SpamAssassin
__________________
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
Reply With Quote
  #3  
Old July 19th, 2012, 15:11
TheDreamer TheDreamer is offline
Junior Member
 
Join Date: May 2012
Location: Manhattan, KS
Posts: 32
Thanks: 2
Thanked 2 Times in 2 Posts
Default

Or use an RBL. We use spamhaus at work.

I also came across this Putting the Spamhaus DROP list in FreeBSD’s ipfw. Perhaps I'll I see what it would take to make it work for ipfilter, since its what we've been using on Solaris.

Think you can also do GeoIP filtering in postfix.

The Dreamer.
Reply With Quote
  #4  
Old July 19th, 2012, 17:17
trwzm trwzm is offline
Junior Member
 
Join Date: Jul 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Since I get login attempts from mostly the same address blocks, it seemed logical to block those address blocks as well.

I do use RBL, which I have to check daily. It seemed like it would cut an enormous amount of traffic to catch it at the firewall.

-Rusty
Reply With Quote
  #5  
Old July 19th, 2012, 17:30
kpa kpa is online now
Giant Locked
 
Join Date: Jul 2010
Location: People's Technocratic Republic of Finland
Posts: 2,017
Thanks: 44
Thanked 468 Times in 398 Posts
Default

Take a look at security/sshguard-ipfw, it's originally designed to block ssh break in attempts but can be made to block based on other types of login attempts, IMAP/POP for example.
Reply With Quote
The Following User Says Thank You to kpa For This Useful Post:
wblock@ (July 19th, 2012)
  #6  
Old July 19th, 2012, 22:34
trwzm trwzm is offline
Junior Member
 
Join Date: Jul 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for the help SirDice, TheDreamer, and kpa. I have a spam filter up and running. The DROP list was a good idea and it added quite a few more addresses than I already had, which is bound to help. I did install sshguard-ipfw, which looks like it should help with security.

Thanks again,

-Rusty
Reply With Quote
  #7  
Old July 22nd, 2012, 05:03
qsecofr qsecofr is offline
Member
 
Join Date: Mar 2009
Location: PDX
Posts: 198
Thanks: 27
Thanked 8 Times in 8 Posts
Default

Not really pertaining to ipfw, but for reducing email spam, the most helpful thing for me has been mail/milter-greylist (combined with spamassassin).

If the traffic is not hitting your smtp server port, then maybe ipfw tables would also help. Not sure if you've tried that versus blocking individual IP addresses each per rule line.
Reply With Quote
  #8  
Old July 22nd, 2012, 14:59
ecazamir ecazamir is offline
Member
 
Join Date: Mar 2009
Posts: 215
Thanks: 5
Thanked 28 Times in 26 Posts
Default

Performance-wise, it's better to use ipfw tables instead of individual 'ipfw add' lines. If the maximum table items is reached, then you can use another method: routing. zebra (from quagga suite) can add a lot of routes to a 'disc' (discard) device.
The best anti-spam approach I've used so far is:
greylisting + postfix + standards compliance checking + rbl lookups + amavisd-new ( + spamassassin ) + antivirus
__________________
My blog: http://ghid-it.blogspot.com
Other guides: http://sites.google.com/site/ghidit/
Reply With Quote
  #9  
Old July 27th, 2012, 09:25
phoenix's Avatar
phoenix phoenix is offline
Moderator
 
Join Date: Nov 2008
Location: Kamloops, BC, Canada
Posts: 3,144
Thanks: 43
Thanked 703 Times in 579 Posts
Default

Second the tables suggestion. Add the IPs to a table, then reference that table in a single IPFW rule. If you too many for a single table, then use more than one. Table lookups are very fast.

Code:
# ipfw table 1 add 1.2.3.4
# ipfw table 1 add 2.3.4.5
# ipfw table 2 add 3.4.5.0/24
# ipfw add 1 unreach host ip from table\(1\) to any in recv em0
# ipfw add 2 unreach host ip from table\(2\) to any in recv em0
__________________
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[IPFW] Rules IPFW djunio Firewalls 4 June 14th, 2012 00:02
[Solved] IPFW Rules danaeckel Firewalls 12 April 16th, 2012 08:46
[Solved] Limit to number of ip addresses per interface dolphinaura Networking 2 March 19th, 2012 02:18
IPFW verbose Limit Junaid Firewalls 1 May 23rd, 2011 05:02
ipfw connections limit bsdfunn Firewalls 3 May 17th, 2011 15:21


All times are GMT +1. The time now is 01:06.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0