<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Minh</title>
    <description>The latest articles on DEV Community by Minh (@minh_57efa2b57b0a5fbb238e).</description>
    <link>https://dev.to/minh_57efa2b57b0a5fbb238e</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4195482%2Fcac750f7-2bab-4093-8e0a-3d73f0755c1b.jpg</url>
      <title>DEV Community: Minh</title>
      <link>https://dev.to/minh_57efa2b57b0a5fbb238e</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/minh_57efa2b57b0a5fbb238e"/>
    <language>en</language>
    <item>
      <title>Basic DDoS Protection for a cPanel/WHM Server Using CSF</title>
      <dc:creator>Minh</dc:creator>
      <pubDate>Tue, 20 Oct 2026 06:37:10 +0000</pubDate>
      <link>https://dev.to/minh_57efa2b57b0a5fbb238e/basic-ddos-protection-for-a-cpanelwhm-server-using-csf-4pa3</link>
      <guid>https://dev.to/minh_57efa2b57b0a5fbb238e/basic-ddos-protection-for-a-cpanelwhm-server-using-csf-4pa3</guid>
      <description>&lt;p&gt;Running a hosting server means sooner or later you will see a flood of requests. You don't need expensive hardware to survive small and medium attacks. A well-tuned firewall goes a long way. This guide covers a practical CSF (ConfigServer Security &amp;amp; Firewall) setup on a cPanel/WHM server.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Find out who is hitting you
&lt;/h2&gt;

&lt;p&gt;Before changing anything, check the current connections per IP:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ss &lt;span class="nt"&gt;-ntu&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'NR&amp;gt;1{print $6}'&lt;/span&gt; | &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="s1"&gt;'s/:[0-9]*$//'&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; | &lt;span class="nb"&gt;uniq&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-nr&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-20&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a single IP holds hundreds of connections, that's your suspect.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Tune CSF in &lt;code&gt;/etc/csf/csf.conf&lt;/code&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="c"&gt;# Limit total connections per IP and block abusers temporarily
&lt;/span&gt;&lt;span class="py"&gt;CT_LIMIT&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"150"&lt;/span&gt;
&lt;span class="py"&gt;CT_INTERVAL&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"30"&lt;/span&gt;
&lt;span class="py"&gt;CT_BLOCK_TIME&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"1800"&lt;/span&gt;
&lt;span class="py"&gt;CT_PORTS&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"80,443"&lt;/span&gt;

&lt;span class="c"&gt;# Limit simultaneous connections per port
&lt;/span&gt;&lt;span class="py"&gt;CONNLIMIT&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"80;50,443;50"&lt;/span&gt;

&lt;span class="c"&gt;# Rate-limit new connections per port (port;proto;hits;seconds)
&lt;/span&gt;&lt;span class="py"&gt;PORTFLOOD&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"80;tcp;100;5,443;tcp;100;5"&lt;/span&gt;

&lt;span class="c"&gt;# SYN flood protection
&lt;/span&gt;&lt;span class="py"&gt;SYNFLOOD&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;
&lt;span class="py"&gt;SYNFLOOD_RATE&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"100/s"&lt;/span&gt;
&lt;span class="py"&gt;SYNFLOOD_BURST&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"150"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apply the changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;csf &lt;span class="nt"&gt;-r&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start with conservative values and watch for false positives (shared NAT, offices, CDNs). Then tighten gradually.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Let LFD handle repeated offenders
&lt;/h2&gt;

&lt;p&gt;Make sure &lt;code&gt;lfd&lt;/code&gt; is running, because it is what enforces &lt;code&gt;CT_LIMIT&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;systemctl status lfd
&lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; /var/log/lfd.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also permanently block an IP manually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;csf &lt;span class="nt"&gt;-d&lt;/span&gt; 203.0.113.50 &lt;span class="s2"&gt;"DDoS source"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Put a proxy in front when attacks get bigger
&lt;/h2&gt;

&lt;p&gt;A firewall on the origin server can't absorb volumetric attacks that saturate your bandwidth. For that, use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cloudflare&lt;/strong&gt; (free tier works well for HTTP floods). After enabling it, restrict ports 80/443 to Cloudflare IP ranges only.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An upstream anti-DDoS provider&lt;/strong&gt; that filters traffic before it reaches your server.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Quick checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] CSF + LFD running and updated&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;CT_LIMIT&lt;/code&gt;, &lt;code&gt;CONNLIMIT&lt;/code&gt;, &lt;code&gt;PORTFLOOD&lt;/code&gt;, &lt;code&gt;SYNFLOOD&lt;/code&gt; configured&lt;/li&gt;
&lt;li&gt;[ ] Origin IP hidden behind a proxy/CDN&lt;/li&gt;
&lt;li&gt;[ ] Regular backups (an attack is not the only way to lose data)&lt;/li&gt;
&lt;li&gt;[ ] Monitoring/alerts for abnormal connection counts&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;CSF won't stop a large volumetric attack alone, but combined with sensible limits and a CDN, it handles most everyday abuse on shared and VPS hosting.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I run &lt;a href="https://dichvucheap.vn" rel="noopener noreferrer"&gt;DichVuCheap&lt;/a&gt;, a small hosting/VPS/domain service in Vietnam, and these are the settings I use day to day. Questions or improvements are welcome in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>security</category>
    </item>
  </channel>
</rss>
