title: How to Block 100,000+ Individual IP addresses
body: <p><strong>Introduction</strong></p>
  
  <p>How do you Block large number of <code>IP address</code> from your web application/server. Obviously that can easily be done in <code>PHP</code> or any programming language </p>
  
  <pre><code>$ipList = []; // array list or from database
  if (in_array(getIP(), $ipList)) {
      // Log IP &amp; Access information
      header("https://www.google.com.ng/search?q=fool"); // redirect
      exit(); // exit
  } 
  </code></pre>
  
  <p>Or Using <code>htaccess</code></p>
  
  <pre><code>order allow,deny
  deny from 123.45.6.7
  deny from 012.34.5.
  # .... the list continues
  allow from all
  </code></pre>
  
  <p><strong>The issues</strong> </p>
  
  <ul>
  <li>Am trying to block a whole <code>100k plus individual IPs</code> not <code>subnets</code>  </li>
  <li>Am trying to avoid user getting to PHP before blocking such IP</li>
  <li>100000+ is over 1.5MB and that is a lot if information to be loading in <code>htaccess</code> all the time</li>
  <li>Database of IP still growing ... and they would be nee to dynamically add more values</li>
  <li>To set bans in <code>iptables</code> for 100000+ is just ridiculous (Might Be wrong)</li>
  </ul>
  
  <p><strong>Stupid Idea</strong> </p>
  
  <pre><code>order allow,deny
  deny from database    &lt;-------- Not sure if this is possible
  allow from all
  </code></pre>
  
  <p><strong>Question</strong> </p>
  
  <ul>
  <li>Is it possible for <code>htaccess</code> to get the list from database (Redis,Crunchbase,Mongo, MySQL or even Sqlite) ... any</li>
  <li>Is there a visible solution to manage such kind of issue in production </li>
  <li>I know the best solution is <code>Block the IPs at the firewall level</code> is there any way to pragmatically add/remove IP to the firewall</li>
  </ul>
  
  <p><strong>Finally</strong> </p>
  
  <p>My approach might be totally wrong ... all I want is a visible solution since spammers and botnets are on the rise ...  </p>
  
  <p>Please this has nothing to do with <code>DOS</code> attack its a simple ... <strong><code>get lost response</code></strong></p>
  
  <p><strong>Update</strong></p>
  
  <ul>
  <li>Firewall : <strong>Cisco PIX 515UR</strong></li>
  </ul>