{"id":3499,"date":"2009-02-27T18:01:20","date_gmt":"2009-02-27T23:01:20","guid":{"rendered":"http:\/\/underhost.com\/blog\/?p=3499"},"modified":"2025-03-07T08:14:32","modified_gmt":"2025-03-07T13:14:32","slug":"installing-basic-automatic-protection-from-dos-and-ddos-attacks-to-your-server","status":"publish","type":"post","link":"https:\/\/underhost.com\/blog\/installing-basic-automatic-protection-from-dos-and-ddos-attacks-to-your-server\/","title":{"rendered":"Updated MARCH 2025: Ultimate Guide to Installing and Configuring DDoS-Deflate for Server Protection"},"content":{"rendered":"<h2><strong>What is DDoS-Deflate?<\/strong><\/h2>\n<p>\nDDoS-Deflate is a lightweight bash script designed to mitigate DDoS attacks by monitoring active connections to your server. It identifies and temporarily blacklists IP addresses exceeding a specified connection limit, using either <strong>iptables<\/strong> or <strong>APF (Advanced Policy Firewall)<\/strong>.\n<\/p>\n<p>\nThis script is simple to set up and works efficiently in minimizing the impact of <strong>malicious traffic spikes<\/strong>, keeping your server stable and secure.\n<\/p>\n<h2><strong>How to Install DDoS-Deflate<\/strong><\/h2>\n<p>\nFollow these steps to install DDoS-Deflate on your server:\n<\/p>\n<pre>\r\ncd \/usr\/local\r\nmkdir mytmp\r\nwget <a href=\"https:\/\/underhost.com\/pub\/install.sh\">https:\/\/underhost.com\/pub\/install.sh<\/a>\r\nchmod 0700 install.sh\r\n.\/install.sh\r\n<\/pre>\n<p>\nOnce the script runs successfully, you\u2019re ready to configure DDoS-Deflate for optimal performance.\n<\/p>\n<h2><strong>Configuring DDoS-Deflate for Maximum Protection<\/strong><\/h2>\n<p>\nDDoS-Deflate allows flexible configuration to match your server&#8217;s security needs. Open the configuration file using:\n<\/p>\n<pre>\r\ncd \/usr\/local\/ddos\r\nnano ddos.conf\r\n<\/pre>\n<p>\nHere\u2019s a breakdown of key settings:\n<\/p>\n<h3><strong>Software Paths (No Need to Modify)<\/strong><\/h3>\n<blockquote><p>\nPROGDIR=&#8221;\/usr\/local\/ddos&#8221;<br \/>\nPROG=&#8221;\/usr\/local\/ddos\/ddos.sh&#8221;<br \/>\nIGNORE_IP_LIST=&#8221;\/usr\/local\/ddos\/ignore.ip.list&#8221;<br \/>\nCRON=&#8221;\/etc\/cron.d\/ddos.cron&#8221;<br \/>\nAPF=&#8221;\/etc\/apf\/apf&#8221;<br \/>\nIPT=&#8221;\/sbin\/iptables&#8221;\n<\/p><\/blockquote>\n<p>\nThese paths indicate where the script files are stored. Unless you have a custom setup, leave them as they are.\n<\/p>\n<h3><strong>Frequency of Execution<\/strong><\/h3>\n<blockquote><p>\nFREQ=1\n<\/p><\/blockquote>\n<p>\nDefines how often (in minutes) the script runs. Adjust based on your server&#8217;s load. After modifying, run:\n<\/p>\n<pre>\r\nddos --cron\r\n<\/pre>\n<h3><strong>Connection Limit<\/strong><\/h3>\n<blockquote><p>\nNO_OF_CONNECTIONS=100\n<\/p><\/blockquote>\n<p>\nThis sets the maximum connections an IP can have before getting blacklisted. A typical range is <strong>40-100<\/strong>, depending on your traffic.\n<\/p>\n<h3><strong>Enabling APF or IPTables<\/strong><\/h3>\n<blockquote><p>\nAPF_BAN=1\n<\/p><\/blockquote>\n<p>\nSet to <strong>1<\/strong> if you have <strong>APF installed<\/strong>. Otherwise, iptables will be used by default. To check if APF is installed, run:\n<\/p>\n<pre>\r\napf\r\n<\/pre>\n<p>\nIf using iptables, ensure the service is running:\n<\/p>\n<pre>\r\nservice iptables start\r\nchkconfig iptables on\r\n<\/pre>\n<h3><strong>Testing Mode<\/strong><\/h3>\n<blockquote><p>\nKILL=1\n<\/p><\/blockquote>\n<p>\nSet to <strong>0<\/strong> if you want to test the script without blocking IPs. Change to <strong>1<\/strong> for real-time protection.\n<\/p>\n<h3><strong>Email Alerts<\/strong><\/h3>\n<blockquote><p>\nEMAIL_TO=&#8221;admin@example.com&#8221;\n<\/p><\/blockquote>\n<p>\nReplace <code>admin@example.com<\/code> with your email to receive notifications about blocked IPs. Set to <code>root<\/code> to disable alerts.\n<\/p>\n<h3><strong>Ban Duration<\/strong><\/h3>\n<blockquote><p>\nBAN_PERIOD=1800\n<\/p><\/blockquote>\n<p>\nDefines how long an IP stays blocked (in seconds). Recommended values are between <strong>1800-3600<\/strong> seconds (30-60 minutes).\n<\/p>\n<h3><strong>Whitelist Trusted IPs<\/strong><\/h3>\n<p>\nTo prevent accidental blocking of your own IPs, add them to the ignore list:\n<\/p>\n<pre>\r\nnano \/usr\/local\/ddos\/ignore.ip.list\r\n<\/pre>\n<p>\nAdd one IP per line and save the file.\n<\/p>\n<h2><strong>How to Uninstall DDoS-Deflate<\/strong><\/h2>\n<p>\nIf you need to remove DDoS-Deflate, run the following commands:\n<\/p>\n<pre>\r\ncd \/usr\/local\/mytmp\r\nwget <a href=\"https:\/\/underhost.com\/pub\/uninstall.ddos\">https:\/\/underhost.com\/pub\/uninstall.ddos<\/a>\r\nchmod 0700 uninstall.ddos\r\n.\/uninstall.ddos\r\n<\/pre>\n<h2><strong>Final Tips for Enhancing DDoS Protection<\/strong><\/h2>\n<ul>\n<li>Use a <strong>Web Application Firewall (WAF)<\/strong> to filter traffic before it reaches your server.<\/li>\n<li>Enable <strong>rate limiting<\/strong> in your web server configuration.<\/li>\n<li>Consider <a href=\"https:\/\/underhost.com\/cloud-vps.php\">Cloud VPS hosting<\/a> with built-in DDoS protection.<\/li>\n<li>Upgrade to <a href=\"https:\/\/underhost.com\/10gbps-dedicated-servers.php\">10Gbps Dedicated Servers<\/a> for high-bandwidth attacks.<\/li>\n<\/ul>\n<p>\nNeed help? Reach out to <a href=\"https:\/\/customerpanel.ca\/client\">UnderHost Customer Support<\/a> for expert assistance.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Protect your server from DDoS attacks with DDoS-Deflate. Learn how to install, configure, and optimize this simple yet powerful bash script for automated IP blacklisting using iptables or APF.<\/p>\n","protected":false},"author":1,"featured_media":5015,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,24,25],"tags":[],"class_list":["post-3499","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-install","category-linux"],"_links":{"self":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/3499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/comments?post=3499"}],"version-history":[{"count":3,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/3499\/revisions"}],"predecessor-version":[{"id":5085,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/3499\/revisions\/5085"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/media\/5015"}],"wp:attachment":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/media?parent=3499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/categories?post=3499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/tags?post=3499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}