{"id":706,"date":"2009-11-26T16:28:36","date_gmt":"2009-11-26T08:28:36","guid":{"rendered":"http:\/\/www.tzlee.com\/blog\/?p=706"},"modified":"2009-11-26T16:29:32","modified_gmt":"2009-11-26T08:29:32","slug":"hardening-linux-and-apache-servers-for-ddos","status":"publish","type":"post","link":"https:\/\/tzlee.com\/blog\/2009\/11\/hardening-linux-and-apache-servers-for-ddos\/","title":{"rendered":"Hardening Linux and Apache Servers for DDoS"},"content":{"rendered":"<p>In my earlier entry I discussed an interesting topic on firewalls and why we don&#8217;t need them. I put a small LAMP server to the test and got my results.<\/p>\n<p>Attack Information:<\/p>\n<ul>\n<li>Type: TCP SYN flood<\/li>\n<li>Max performance: 26Kpps (8Mbps)<\/li>\n<li>Source IP Spoofing: Yes<\/li>\n<\/ul>\n<p>Victim A Specifications:<\/p>\n<ul>\n<li>VMware Guest on a Single Core Opteron 1.8GHz Sun X2100<\/li>\n<li>CentOS 4.x + Apache 2.x<\/li>\n<li>768MB RAM<\/li>\n<li>Tuned (see below)<\/li>\n<\/ul>\n<p>Here&#8217;s what I&#8217;ve added to tune the Linux TCP stack in <code>\/etc\/sysctl.conf<\/code>:<\/p>\n<blockquote><p><code><br \/>\nnet.ipv4.tcp_abort_on_overflow = 1<br \/>\nnet.ipv4.tcp_fin_timeout = 15<br \/>\nnet.ipv4.tcp_low_latency = 1<br \/>\nnet.ipv4.tcp_syncookies = 1<br \/>\nnet.ipv4.tcp_max_syn_backlog = 2048<br \/>\nnet.ipv4.tcp_synack_retries = 3<br \/>\nnet.ipv4.tcp_sack = 0<br \/>\nnet.ipv4.ip_conntrack_max = 65535<br \/>\nnet.core.rmem_max = 16777216<br \/>\nnet.core.wmem_max = 16777216<br \/>\nnet.ipv4.tcp_rmem = 4096 87380 16777216<br \/>\nnet.ipv4.tcp_wmem = 4096 65536 16777216<br \/>\nnet.ipv4.ip_local_port_range = 1024 65000<br \/>\nnet.ipv4.tcp_keepalive_intvl = 15<br \/>\nnet.ipv4.tcp_keepalive_probes = 4<br \/>\nnet.ipv4.tcp_keepalive_time = 1800<br \/>\n<\/code><\/p><\/blockquote>\n<p>Here&#8217;s what I&#8217;ve added to the top of my iptables configuration in <code>\/etc\/sysconfig\/iptables<\/code> as well:<\/p>\n<blockquote><p><code><br \/>\n-N SYN<br \/>\n-A SYN -m limit --limit 20\/s --limit-burst 50 -j RETURN<br \/>\n-A SYN -j DROP<br \/>\n-A INPUT -p tcp --syn -j SYN<br \/>\n<\/code><br \/>\n* Note: During my testing, I added a log entry before dropping the packet as this floods the logs and kills the CPU and I\/O so I highly discourage doing so.\n<\/p><\/blockquote>\n<p>I repeated the same test on another VM running in a much more powerful Dell 2850 and with no modifications to the kernel or iptables.<\/p>\n<p>Victim B Specifications:<\/p>\n<ul>\n<li>VMware Guest on a 2 x Dual Core Xeon 3.2GHz Dell 2850<\/li>\n<li>CentOS 5.x + Apache 2.x<\/li>\n<li>256MB RAM<\/li>\n<li>No Tuning<\/li>\n<\/ul>\n<p>Results:<\/p>\n<ul>\n<li>Victim A held up to 16Kpps SYN flood (approx 5Mbps) but slowed down a little<\/li>\n<li>Victim A held up to respond at 26Kpps SYN flood (approx 8Mbps) but was extremely slow<\/li>\n<li>Victim B held up to 26Kpps SYN flood (approx 8Mbps) and did not slow down at all<\/li>\n<\/ul>\n<p>At this point in time, I couldn&#8217;t generate any more SYN packets as I lacked the hardware to do so, but it has given some conclusive results that a reasonably powerful LAMP hardware could take on modest DDoS attacks if configured correctly. I would expect a bare metal hardware with decent CPU performance to hold up much much more than what I&#8217;ve tested.<\/p>\n<p>Time to ditch that firewall!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my earlier entry I discussed an interesting topic on firewalls and why we don&#8217;t need them. I put a small LAMP server to the test and got my results. Attack Information: Type: TCP SYN flood Max performance: 26Kpps (8Mbps)&#8230; <a class=\"more-link\" href=\"https:\/\/tzlee.com\/blog\/2009\/11\/hardening-linux-and-apache-servers-for-ddos\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[8],"tags":[114,118,119,123],"class_list":["post-706","post","type-post","status-publish","format-standard","hentry","category-tech","tag-ddos","tag-firewall","tag-iptables","tag-syn-flood"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tzlee.com\/blog\/wp-json\/wp\/v2\/posts\/706","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tzlee.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tzlee.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tzlee.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/tzlee.com\/blog\/wp-json\/wp\/v2\/comments?post=706"}],"version-history":[{"count":2,"href":"https:\/\/tzlee.com\/blog\/wp-json\/wp\/v2\/posts\/706\/revisions"}],"predecessor-version":[{"id":708,"href":"https:\/\/tzlee.com\/blog\/wp-json\/wp\/v2\/posts\/706\/revisions\/708"}],"wp:attachment":[{"href":"https:\/\/tzlee.com\/blog\/wp-json\/wp\/v2\/media?parent=706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tzlee.com\/blog\/wp-json\/wp\/v2\/categories?post=706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tzlee.com\/blog\/wp-json\/wp\/v2\/tags?post=706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}