0

I use the Drupal Core IP blocking feature (/admin/config/people/ip-blocking) to block IP addresses during spam attacks. However, as most of these will be dynamic ones owned by legitimate users a day later, I want to remove these blocks.

I could delete them one by one in the IP blocking interface, but with dozens of addresses, that is not a comfortable way. Any alternative?

0

There are several options, choose depending on your requirements:

  • You can use module Blocked IPs Expire to add an expiration date to IP blocks when adding them. The Drupal cron job will remove the blockings after expiry.

  • You can remove all of the IP blockings at once with this drush command:

    drush sql-query "TRUNCATE TABLE blocked_ips"
    
  • You can remove just some IP blockings (e.g. an IP range) with similar drush commands. For example to delete all IPv4 blocks:

    drush sql-query "DELETE FROM blocked_ips WHERE ip LIKE '%.%.%.%'"
    

Note that auto-banning users and IP addresses after a number of unsuccessful login attempts is a different Drupal Core mechanism, resulting in entries in table floodmore details. To remove these bans, the Flood Unblock module can help you. (But that mechanism is out of the scope of this question anyway.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.