Skip to content

Repository files navigation

🛠️ ros-scripts

English version: README.md | Русская версия: README_ru.md

A collection of useful scripts for MikroTik RouterOS.

License MikroTik


📚 Table of Contents


📦 Scripts

Script Description Min. ROS Version
anomalyze Anomaly detection and blocking 7.20+
asn-to-address-list Auto-update address lists by ASN 7.10+
cloudflare-ddns Dynamic Cloudflare DNS updates 7.20+
resolve-address-lists DNS resolution of IP addresses in comments 7.20+
warp-finder Auto-discovery of working Cloudflare WARP endpoints 7.20+

🔍 anomalyze

Anomalous connection detection and automatic blocking

This script monitors active connections and identifies suspicious patterns: asymmetric packet counts (high outgoing, low incoming). Useful for protection against port scans, DoS attacks, and TLS handshake timeouts.

Features:

  • 🎯 Smart asymmetric connection detection
  • 🚫 Automatic IP blocking
  • ✅ Allowlist support for trusted IPs
  • 🔒 Local router address protection
  • 📊 Flexible logging (debug/info/warning/error)
  • ⚡ Configurable detection thresholds

Files:

Quick Start:

# Copy script to System → Scripts
# Run
/system script run connection-monitor

Configuration:

:global cfgMonitoredPorts {443; 80; 8443}
:global cfgMinOrigPackets 3
:global cfgMaxReplPackets 2
:global cfgBlockTimeout "1d"

📖 Full Documentation →


🌐 asn-to-address-list

Automatic address list updates by ASN number

Fetches up-to-date IPv4/IPv6 prefix lists for any ASN from ipverse/as-ip-blocks and adds them to firewall address-list.

Features:

  • ✅ Auto-update from ipverse GitHub
  • 🌐 IPv4 and IPv6 support
  • 🔢 Multiple ASN processing in a single run
  • 🔄 Smart cleanup of old entries
  • 💾 Flexible storage (USB/disk/tmpfs)

Files:

Quick Start:

# Update Cloudflare IPv4
:global UAPASN "13335"
:global UAPLIST "cloudflare-v4"
/system script run update-asn-prefixes

# Multiple ASNs at once
:global UAPASN "13335,16509,15169"
:global UAPLIST "cdn-networks"
/system script run update-asn-prefixes

Popular ASNs:

Company ASN Description
Cloudflare 13335 CDN and security
Google 15169 Google infrastructure
Amazon 16509 AWS
Microsoft 8075 Azure
Meta 32934 Facebook, Instagram

📖 Full Documentation →


☁️ cloudflare-ddns

Dynamic Cloudflare DNS record updates

Automatically updates A/AAAA records in Cloudflare when your router's public IP address changes. Supports both IPv4 and IPv6.

Features:

  • ✅ IPv4 and IPv6 support
  • 🌐 Multiple domains simultaneously
  • 🔶 Cloudflare Proxy toggle (orange/gray cloud)
  • ⚡ IP change detection before updates
  • 🔄 Scheduled automation

Files:

Quick Start:

# 1. Enable IP Cloud
/ip cloud set ddns-enabled=yes

# 2. Configure script (specify token, Zone ID, Record ID)
# 3. Create scheduler
/system scheduler add \
  name=cloudflare-ddns-update \
  on-event=cloudflare-ddns \
  interval=5m \
  start-time=startup

Domain Configuration:

:local domains {
    "example.com,ZONE_ID,RECORD_ID,true,v4";
    "ipv6.example.com,ZONE_ID,RECORD_ID,false,v6"
}

📖 Full Documentation →


🔄 resolve-address-lists

DNS resolution of IP addresses in firewall address-list

Automatically resolves IP addresses in specified address lists and stores hostnames in comments for easy identification.

Features:

  • 🌐 IPv4 and IPv6 support
  • 🔧 Custom DNS server selection (Cloudflare, Google, Quad9)
  • 📝 Updates only empty comments
  • ⚙️ Flexible list configuration

Files:

Quick Start:

# Configure lists for resolution
:local dnsServer "1.1.1.1"
:local ipVersion "both"

:local ipv4ListsToResolve {
    "Trap";
    "MYDNS";
}

:local ipv6ListsToResolve {
    "Trap-v6";
    "MYDNS-v6";
}

# Run
/system script run resolve-address-lists

📖 Full Documentation →


📡 warp-finder

Automatic Cloudflare WARP endpoint discovery

Automatically tests various IP:port combinations from Cloudflare's infrastructure to find a working WireGuard endpoint.

Features:

  • 🔄 Automatic endpoint discovery
  • 🎯 Random IP:port generation
  • 🏥 Connectivity testing via ping
  • 📊 Detailed logging
  • 🛡️ Safe operation with rollback

Files:

Quick Start:

# Configure interface
:local wgInterface "cloudflare-interface"
:local maxAttempts 10

# Run
/import warp-finder.rsc

Scheduler for auto-run:

/system scheduler add \
  name="warp-finder" \
  interval=6h \
  on-event="/import warp-finder.rsc"

📖 Full Documentation →


📋 Requirements

Script Minimum RouterOS Version
anomalyze 7.20+
asn-to-address-list 7.10+
cloudflare-ddns 7.20+
resolve-address-lists 7.20+
warp-finder 7.20+

Common Requirements:

  • Administrative access to the router
  • Internet connectivity
  • system package enabled

🚀 Installation

Method 1: Via WebFig/WinBox (Recommended)

  1. Open System → Scripts
  2. Click + (Add New)
  3. Specify the script name
  4. Copy the .rsc file contents into the Source field
  5. Click OK

Method 2: Via Terminal/SSH

# Connect to the router
ssh admin@192.168.88.1

# Import the script
/import script-name.rsc

Method 3: File Upload

# Upload the script to the router
scp script.rsc admin@192.168.88.1:/

# Import
ssh admin@192.168.88.1
/import script.rsc

🤝 Contributing

Contributions are welcome:

  • 🐛 Bug reports
  • 💡 Feature suggestions
  • 🔧 Pull requests with fixes
  • 📖 Documentation improvements

How to Contribute

  1. Fork the repository
  2. Create a branch (git checkout -b feature/improvement)
  3. Make your changes
  4. Test on RouterOS
  5. Submit a Pull Request

📄 License

MIT License — see the LICENSE file for details.


⚠️ Disclaimer

Scripts are provided "as is" without any warranties. Use at your own risk. Testing in a non-production environment is recommended before deployment.


🔗 Useful Links


Made with ❤️ for the MikroTik community

GitHub IssuesPull Requests

About

some useful mikrotik scripts

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages