Convert ad-blocking filter lists to MikroTik RouterOS DNS adlist format.
Note
This is a Rust rewrite of adblock2mikrotik
Tip
Ready-to-use URL for RouterOS:
https://raw.githubusercontent.com/eugenescodes/adblock2mikrotik_rust/refs/heads/main/hosts.txt
Transforms popular ad-blocking filter lists (Hagezi) into a compact format compatible with the MikroTik RouterOS 7.15+ DNS adlist feature. Optimized for memory-constrained low-resource devices like the RB951Ui-2nD hAP (which has 16 MB storage).
| List | Description |
|---|---|
| Hagezi Multi PRO mini | General ad/tracker blocking |
| Hagezi TIF mini | Threat intelligence feeds |
| Hagezi Gambling mini | Gambling sites |
- Converts
||example.com^rules to MikroTik DNS adlist format (0.0.0.0 example.com) - Deduplicates entries across all sources
- Validates domains against RFC label rules (rejects double-dots, leading/trailing hyphens)
- Pre-filters comments and empty lines for efficiency
- Compatible with RouterOS 7.15+
# Install Rust if not already installed
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Clone and run
git clone https://github.com/eugenescodes/adblock2mikrotik_rust
cd adblock2mikrotik_rust
cargo run --releaseAfter running, hosts.txt is created in the current directory.
docker build -t adblock2mikrotik_rust .Important
If hosts.txt does not exist in your current directory, Docker might create it as a directory. Create the file first:
touch hosts.txt# Linux / macOS
docker run --rm --user $(id -u):$(id -g) -v "$(pwd)":/output adblock2mikrotik_rust
# Windows (PowerShell)
docker run --rm -v "${PWD}:/output" adblock2mikrotik_rustNote
The -v flag mounts your current directory into the container at /output.
The binary writes hosts.txt to /output, so the file appears directly
in your current directory on the host — no manual copying needed.
On Linux, --user $(id -u):$(id -g) ensures the output file is owned by
your current user. Not required on macOS or Windows (Docker Desktop handles this automatically).
/ip/dns/adlist add url=https://raw.githubusercontent.com/eugenescodes/adblock2mikrotik_rust/refs/heads/main/hosts.txt ssl-verify=no
If you want to use ssl-verify=yes, you can download and import CA certificates using the following commands:
/tool fetch url=https://curl.se/ca/cacert.pem
/certificate import file-name=cacert.pem passphrase=""
/ip/dns/adlist add url=https://raw.githubusercontent.com/eugenescodes/adblock2mikrotik_rust/refs/heads/main/hosts.txt ssl-verify=yes
/ip/dns/adlist add file=hosts.txt
See also the official MikroTik documentation:
By default, the script uses three pre-configured Hagezi filter lists. You can customize which sources are used by creating a config.toml file:
- Copy the example configuration:
cp config.toml.example config.toml- Edit
config.tomlto add or remove sources:
[sources]
urls = [
"https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/pro.mini.txt",
"https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/tif.mini.txt",
"https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/gambling.mini.txt",
]- Run the converter:
cargo run --releaseThe script will automatically load sources from config.toml. If the file doesn't exist, it falls back to the default sources above.
You can use any blocklist in AdBlock format (||domain.com^ syntax)
For more Hagezi lists, visit the Hagezi DNS blocklists repository
This project uses Cargo for dependency management and Clippy + rustfmt for linting/formatting.
Install Rust via rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh# format
cargo fmt --all
# lint
cargo clippy --all-targets --all-features -- -D warnings cargo test --verbose
cargo test --doc- Open a GitHub issue to discuss major changes before starting work.
- Fork the repo and create a feature branch:
git checkout -b feature/your-feature - Make your changes and run tests:
cargo test --verbose - Commit with a clear message and push to your fork.
- Open a Pull Request targeting
mainwith a description of what and why.
- Hagezi for maintaining comprehensive filter lists
- MikroTik for the DNS adlist feature in RouterOS 7.15+
This tool is not affiliated with MikroTik.