Skip to content

Export WordPress firewall rules

A ban inside WordPress costs a full load of the application on every visit. A ban at the web server costs nothing.

Firewall Export add-on in BotBlocker Security

Refuse the visit before PHP wakes up

The server answers first. Give it the same list that BotBlocker already keeps.

Where the ban happens now

BotBlocker blocks a bad visitor inside WordPress. That works, but every blocked visit still loads the database, the plugins and the theme before the decision is made. Under a flood the site spends its memory on requests it will refuse.

The web server sees each visitor first and knows nothing about your ban list. An export closes that gap: the list becomes a file that Apache, nginx, fail2ban or iptables reads without asking PHP.

A server that refuses a known attacker keeps the worker free for real visitors, so a payment page stays available while a flood is running.

Four formats, one list

Apache

A single htaccess fragment with deny rules. It works on old and new Apache versions without extra modules.

nginx

A configuration snippet with one deny line per address, ready to include inside a server block.

fail2ban

A shell script that creates a jail, reloads the service and bans every address from the export.

iptables

A script that builds its own chain for IPv4 and a second chain for IPv6, then fills both with drop rules.

Which bans travel to the server

The export follows the kind of rule, not the single entry. Blocked addresses are the main part and are on by default. Temporary bans are on as well, so a rate limit that fired five minutes ago is already at the server. Expired entries and rules you switched off stay out.

Dark and gray rules are the judgement call. A dark rule sends a visitor to the check page, where a real person can still pass. A server file can only say yes or no, so exporting dark rules refuses those visitors outright. Gray rules are weaker still: they only mark a visitor as suspicious. Both switches are easy to leave on and both cost you real readers.

Allow rules never leave WordPress. They are the one part of the list that must not become a deny line by accident.

A snapshot, not a live link

The file is a copy of the list at one moment. A ban added after the download is not in it, and a ban removed in BotBlocker stays active at the server until a new file replaces the old one.

The two scripts differ on a second run. The iptables script empties its chain and fills it again, so addresses that left the list stop being blocked. The fail2ban script only adds bans, and the default ban time has no end. An address removed from the export stays banned in fail2ban until someone unbans it by hand.

A temporary ban also outlives its end time on the server, because a static file has no clock. Export again after an attack, and on a schedule that matches how often your list changes.

Settings worth a look

Extra addresses

Your own ranges, one per line, appended to every export. Never add your own address: the server will refuse you and BotBlocker cannot let you back in.

fail2ban ban time

A number of seconds or a value such as 24h. The default keeps an address banned until someone removes it.

nginx path note

Only changes the comment at the top of the snippet. Set it to the real location so the include line is correct.

One of hundreds of BotBlocker capabilities

This add-on covers one job. The core plugin brings the firewall, the visitor check, the login rules and the log; PRO features extend them further. Install BotBlocker, turn on what your site needs and leave the rest off.

BotBlocker protection shield

Questions about the export

Do blocked visitors still appear in my logs?
No. A request refused by the server never reaches WordPress, so BotBlocker cannot record it. Count those visits in the server access log instead.
Should I export dark and gray rules?
Only when those lists hold networks you never want to see. Otherwise you refuse people who would have passed the check page.
I locked myself out. How do I get back?
Remove your address from the installed file and reload the server. Then remove the ban in BotBlocker, or the next export puts it back.
An unblocked address is still refused.
The old file still contains it. Export again and install the new copy. With fail2ban, also unban the address in the jail by hand.
Why does the file say no active bans matched?
No rule fits the switches you saved. Enable another rule type or add extra addresses, then save before you download. The fail2ban documentation explains jails and ban times.