All of lore.kernel.org
 help / color / mirror / Atom feed
* Block outgoing spam from a network using iptables?
@ 2009-05-07  9:36 Fredrik Strömberg
  2009-05-08 15:52 ` Michele Petrazzo - Unipex
  0 siblings, 1 reply; 2+ messages in thread
From: Fredrik Strömberg @ 2009-05-07  9:36 UTC (permalink / raw)
  To: netfilter

Hello,

I´m using iptables on a gateway for a lot of computers. I want to  
block spam that goes out through the gateway, namely, I want to block  
certain traffic to dport 25.

Scanning the contents of the emails is not an option, so I need some  
kind of rules that say something like "If ip-adress X sends more than  
Y emails within Z minutes, that ip will be logged and blocked from  
sending mail for C hours, and if the sending persists for D minutes,  
log that too".

I´ve googled my problem but have been unable to find much. I don´t  
expect a complete solution, just suggestions and hints. Although, a  
complete solution would be nice to study and learn from, if someone  
here is able to do it.

Maybe logging how many emails is impossible. If so, what is the best  
solution you can think of that doesn´t involve scanning the contents?

I found this but I don´t understand how it does what he says it does.  
- http://marti.dimerge.net/blog/tag/ipt_recent :

modprobe ipt_recent ip_list_tot=32 #ip_list_tot - defines the size of  
ip_recent file
iptables -A FORWARD -p tcp –dport 25 -m recent –name SMTP –seconds 30 – 
update -j DROP
iptables -A FORWARD -p tcp –dport 25 -m limit –limit 1/second –limit- 
burst 5 -j LOG –log-level info –log-prefix “smtp-log ”
iptables -A FORWARD -p tcp –dport 25 -m recent –name SMTP –set -j ACCEPT

If this is the wrong list and I should look for help somewhere else,  
please say so.


Kind regards, stromberg

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Block outgoing spam from a network using iptables?
  2009-05-07  9:36 Block outgoing spam from a network using iptables? Fredrik Strömberg
@ 2009-05-08 15:52 ` Michele Petrazzo - Unipex
  0 siblings, 0 replies; 2+ messages in thread
From: Michele Petrazzo - Unipex @ 2009-05-08 15:52 UTC (permalink / raw)
  To: Fredrik Strömberg; +Cc: netfilter

Fredrik Strömberg wrote:
> Hello,
> 
> I want to block spam that goes out through the gateway, namely, I 
> want to block certain traffic to dport 25.

> I don´t expect a complete solution, just suggestions and hints. 
> Although, a complete solution would be nice to study and learn from,
>  if someone here is able to do it.
> 

Like now I do the same job with iptables, some per user match rules and
a python parser that make the control of the "iptables -nvL && iptables
-Z" output and send an email to user if the limit are passed

> Maybe logging how many emails is impossible. If so, what is the best
>  solution you can think of that doesn´t involve scanning the
> contents?
> 
> 

a simple iptables -A FORWARD -p tcp --dport 25 -m state --state NEW -j
log --log-prefix "NEW EMAIL" or something like this

> I found this but I don´t understand how it does what he says it does.
>  - http://marti.dimerge.net/blog/tag/ipt_recent :
> 
> modprobe ipt_recent ip_list_tot=32 #ip_list_tot - defines the size of
>  ip_recent file iptables -A FORWARD -p tcp –dport 25 -m recent –name
>  SMTP –seconds 30 –update -j DROP iptables -A FORWARD -p tcp –dport
> 25 -m limit –limit 1/second –limit-burst 5 -j LOG –log-level info 
> –log-prefix “smtp-log ” iptables -A FORWARD -p tcp –dport 25 -m 
> recent –name SMTP –set -j ACCEPT
> 

what's to understand?  if someone send more than one email into the next
30 seconds, the match extension will drop it
have you read the iptables -> recent man page?

Michele


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-05-08 15:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-07  9:36 Block outgoing spam from a network using iptables? Fredrik Strömberg
2009-05-08 15:52 ` Michele Petrazzo - Unipex

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.