Skip to content
Home » Linux » How to Maintain Blacklist for IPTables Atomatically

How to Maintain Blacklist for IPTables Atomatically

Several sources provide IP blacklist free to download, you can leverage the blacklist to plan the blocking policies for your own firewall.


Assuming that we have three different sources of blacklist, one is a local-maintained blacklist at /path/to/blacklist_local, two external sources from internet as listed above. All the sources will be combined into a finalized blacklist /path/to/blacklist. Let's see the steps:

  1. Create an executable script for maintaining the blacklist.
  2. [root@test ~]# vi /path/to/

    # Copy the local-maintained blacklist to the final blacklist
    cat $WDIR/blacklist_local > $IPLT

    # Download the blacklists from Internet and add them to the final blacklist
    curl -s >> $IPLT
    curl -s >> $IPLT
  3. Make the script executable
  4. [root@test ~]# chmod u+x /path/to/
  5. Schedule the job in cron table
  6. [root@test ~]# crontab -e
    0 0 * * * sh /path/to/

    I scheduled the job to be executed every day.

Next, you should plan to apply the blacklist into IPTables, you may refer to my post for more implementations: How to Block Blacklist in IPTables.

Leave a Reply

Your email address will not be published. Required fields are marked *