Limit module accept negation?
Can I replace this two rules
iptables -A INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 4 -j ACCEPT iptables -A INPUT -p tcp --syn -j DROP
For only this one? (Using negation)
iptables -A INPUT -p tcp --syn -m limit ! --limit 1/s --limit-burst 4 -j DROP
Thanks in advanced
**********************************
CTO: Eng. Jorge Agrelo O.
WEb: www.novadevices.com
E-Mail: [email protected]
Phone: (593-2) 225-7711 ext. 105
Av. Brasil N45-08 y Condor, Quito Ecuador
**********************************
Quoted 10 lines · Jorge Agrelo
Can I replace this two rules
iptables -A INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 4 -j ACCEPT
iptables -A INPUT -p tcp --syn -j DROPFor only this one? (Using negation)
iptables -A INPUT -p tcp --syn -m limit ! --limit 1/s --limit-burst 4 -j DROP
Unfortunately, you can't without a bit of hacking. If it happens you would, just grab ipt_limit.c and search for:
/* We're underlimit */
Change the return codes so it returns 0 when 'underlimit', otherwise, 1. Am sorry if this is straigh, I am at work.
Note that this won't add '!' support but just doesn't match unless it bursts the limit.
By the way, do you want to limit as soon as you receive more than 1/s packet regardless of the source address?
Quoted 2 lines
Thanks in advanced
HTH,
Samuel
Hi Samuel
Yes, I want to limit (drop) as soon as we receive more than 1/s packet regardless of the source address?, Is there any other way to do that without using limit match with negation?
Regards
Quoted 33 lines · Samuel Jean
Quoted 10 lines · Jorge Agrelo
Can I replace this two rules
iptables -A INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 4 -j ACCEPT
iptables -A INPUT -p tcp --syn -j DROPFor only this one? (Using negation)
iptables -A INPUT -p tcp --syn -m limit ! --limit 1/s --limit-burst 4 -j DROP
Unfortunately, you can't without a bit of hacking. If it happens you would, just grab
ipt_limit.cand search for:/* We're underlimit */
Change the return codes so it returns 0 when 'underlimit', otherwise, 1. Am sorry if this is straigh, I am at work.
Note that this won't add '!' support but just doesn't match unless it bursts the limit.By the way, do you want to limit as soon as you receive more than 1/s packet regardless of the source address?
Quoted 2 lines
Thanks in advanced
HTH,
Samuel
Quoted 3 lines · Jorge Agrelo
Yes, I want to limit (drop) as soon as we receive more than 1/s packet regardless of the source address?, Is there any other way to do that without using limit match with negation?
AFAIK, there isn't.
Quoted 3 lines
Regards
The patch below is against ipt_limit.c from 2.6.10. It's *untested* but reflects what I told you. It's just an exemple of how you can make this module behaving the other way arround.
(NOTE: ipt_limit.c was written to avoid flooding -j LOG)
HTH,
Samuel
ipt_limit.c.orig renamed from ipt_limit.c +2 -2
@@ -82,11 +82,11 @@ /* We're not limited. */ r->credit -= r->cost; spin_unlock_bh(&limit_lock); - return 0; + return 1; } spin_unlock_bh(&limit_lock); - return 1; + return 0; } /* Precision saver. */
Quoted 3 lines · Samuel Jean
The patch below is against
ipt_limit.cfrom 2.6.10. It's *untested* but reflects what I told you. It's just an exemple of how you can make this module behaving the other way arround.
Doh! crapy patch. Attached good one. I hope.
ipt_limit.c renamed from ipt_limit.c.orig +2 -2
@@ -82,11 +82,11 @@/* We're not limited. */ r->credit -= r->cost;spin_unlock_bh (&limit_lock); -return 1 ; +return 0 ; }spin_unlock_bh (&limit_lock); -return 0 ; +return 1 ; }/* Precision saver. */
Thanks Samuel, after I apply the patch, How look like the rule with limit to drop packets flowing above 1p/s
Regards
Quoted 8 lines · Samuel Jean
Quoted 4 lines · Samuel Jean
The patch below is against
ipt_limit.cfrom 2.6.10. It's *untested* but reflects what I told you. It's just an exemple of how you can make this module behaving the other way arround.Doh! crapy patch. Attached good one. I hope.
Quoted 2 lines · Jorge Agrelo
Thanks Samuel, after I apply the patch, How look like the rule with limit to drop packets flowing above 1p/s
iptables -I INPUT -m limit --limit 1/s -j DROP
Let me know if that didn't work.
Quoted 1 line
Regards
Cheers,
Samuel