0

This question already has an answer here:

I'm trying to set up some basic DOS protection. The following iptables rule works on a CentOS box but NOT on debian (wheezy).

#limit the parallel http requests to 50 per class C sized network    
iptables  -A INPUT -p tcp --syn --dport 80 -m connlimit --connlimit-above 50 --connlimit-mask 24 -j REJECT --reject-with tcp-reset

I'm using the GoldenEye DOS tool (among others), and in the CentOS connections are successfully denied, however in the debian box nothing happens (CPU goes up to 100%, apache becomes unresponsive)

Any idea of what might be happening? The rule is succesfully added to the IPTABLES rule list

root@bedrock ~ # iptables -L | grep httpflags
REJECT     tcp  --  anywhere             anywhere             tcp dpt:httpflags: FIN,SYN,RST,ACK/SYN #conn src/24 > 50 reject-with tcp-reset

root@bedrock ~ # cat /etc/*-release
PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"

root@bedrock ~ # lsmod | grep ip
xt_multiport           12548  12
ipt_REJECT             12502  3
ipt_LOG                12605  8
iptable_mangle         12536  0
iptable_nat            12928  0
nf_nat                 18242  1 iptable_nat
nf_conntrack_ipv4      14078  16 nf_nat,iptable_nat
nf_defrag_ipv4         12483  1 nf_conntrack_ipv4
nf_conntrack           52720  5 nf_conntrack_ipv4,nf_nat,iptable_nat,xt_state,xt_connlimit
ip6table_filter        12540  0
ip6_tables             22175  1 ip6table_filter
iptable_filter         12536  1
ip_tables              22042  3 iptable_filter,iptable_nat,iptable_mangle
x_tables               19118  14 ip_tables,iptable_filter,ip6_tables,ip6table_filter,iptable_nat,iptable_mangle,xt_tcpudp,xt_state,xt_limit,ipt_LOG,ipt_REJECT,xt_multiport,xt_recent,xt_connlimit

marked as duplicate by HopelessN00b Feb 18 '15 at 6:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Do you have more rules in INPUT chain that might interfere (specially any containing ACCEPT)? Can you paste a iptables -nvL INPUT ? – LatinSuD Jun 9 '14 at 10:26
  • We really need to see the full state of your iptables INPUT chain iptables -L -vn. – Iain Jun 9 '14 at 10:26
1

This will almost certainly be a rule ordering issue. Iptables/netfilter stops processing packets when a rule matches. Using the -A switch adds rules to the end of the chain so it's likely that you have an earlier rule that causes processing to stop.

  • Thanks Iain, moved the rule to the top of the INPUT chain and it now gets triggered. Cheers! – Iraklis Jun 9 '14 at 11:09
  • Just for the record, if you use -I instead of -A it will place the rule at the begining of the chain. – LatinSuD Jun 9 '14 at 11:36
  • 2
    @Iraklis In this sort of case you really should define your own chain and throw all your rules in it. Makes things much cleaner and helps avoid problems like this. – Michael Hampton Jun 9 '14 at 12:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.