Fail2Ban for Mikrotik via API
197
# General settings
DEBUG = "False"
# Syslog settings
LISTEN_PORT = 1514
# Blocking settings
MAX_RETRIES = 5
FIND_TIME_SECONDS = 3600
BAN_TIME_SECONDS = 86400
# Mikrotik settings
MIKROTIK_API_USERNAME = "admin"
MIKROTIK_API_PASSWORD = "mysecretpassword"
MIKROTIK_API_HOST = "<MIKROTIK-IP>"
MIKROTIK_ADDRESS_LIST_NAME = "fail2ban"
CREATE_BLOCK_RULE = "True"
services:
app:
build: .
image: f145hka/mikrotik-fail2ban:latest
container_name: mikrotik-fail2ban
restart: unless-stopped
volumes:
- db_data:/app/db
env_file:
- .env
ports:
- "${LISTEN_PORT:-1514}:${LISTEN_PORT:-1514}/udp"
volumes:
db_data:
ip/service/enable api
ip/service/set api address=<DOCKER-HOST-IP>
system/logging/add topics=error,system,critical action=remote
system/logging/action/add name="remote" target=remote remote=<DOCKER-HOST-IP> remote-port=1514 src-address=0.0.0.0 remote-log-format=default remote-protocol=udp vrf=main
docker exec mikrotik-fail2ban python main.py --help
usage: main.py [-h] [--unlock IP] [--clear] [--list]
Mikrotik Fail2Ban
options:
-h, --help show this help message and exit
--unlock IP IP address to unlock
--clear Clean DB and Mikrotik address list
--list List blocked IP
# docker exec mikrotik-fail2ban python main.py --list
IP: 178.176.76.80, attempts: 3, last: 30.07.2026 16:17, blocked: yes
IP: 179.43.186.241, attempts: 1, last: 30.07.2026 20:17, blocked: no
Content type
Image
Digest
sha256:b4bd92390…
Size
24 MB
Last updated
about 2 months ago
docker pull f145hka/mikrotik-fail2ban