tikoci/routeros-skills/routeros-firewall
Claude Code and agent skill by tikoci/routeros-skills
- community
Checking that the SKILL.md file is still in the repository.
RouterOS firewall filter, NAT, mangle, and address-list configuration. Use when: writing firewall rules in RouterOS, configuring NAT, setting up address-lists or interface-lists, writing idempotent firewall scripts, configuring DNS redirect or port forwarding, or when the user mentions /ip/firewall, chain=forward, chain=input, connection-state, address-list, interface-list, or layer7-protocol on MikroTik.
Install
npx vskill@latest install tikoci/routeros-skills/routeros-firewallSKILL.md
RouterOS Firewall
Rule Ordering — Sequential, Not Priority-Based
Rules are evaluated top-to-bottom — first match wins. This is the biggest source of iptables confusion.
place-before=0inserts at the top; defaultaddappends at the bottom- An
action=acceptrule must appear BEFORE anyaction=dropfor the same traffic - Non-terminal actions do NOT stop evaluation:
action=add-src-to-address-list,action=add-dst-to-address-list,action=log, and any rule withpassthrough=yescontinue to the next rule. Adroprule below anadd-src-to-address-listwill still fire.
Address-Lists as Dynamic Selectors
LLMs rarely suggest this pattern — they write one rule per IP address instead. Address-lists scale to hundreds of IPs with a single firewall rule.
Dynamic entries with timeout= expire automatically — the primary pattern for DoS blacklists.
Interface-Lists as Rule Selectors
in-interface-list= / out-interface-list= — powerful RouterOS pattern LLMs never propose. Eliminates duplicate rules when multiple interfaces serve the same role.
Comment-as-Tag Pattern (Idempotent Scripts)
RouterOS has no "upsert" — re-running a script without cleanup creates duplicate rules. Use a comment prefix as a tag:
Never use `remove [find dynamic=no]` — this deletes ALL static rules including those added by management tools. Some tools (e.g. OptiWize) mark their rules with comment~"#orchestrator-*" — a bulk remove silently breaks remote management.
Connection State
RouterOS connection-state= is not iptables -m state:
RouterOS states: new, established, related, invalid, untracked.
untracked matches packets explicitly marked via /ip/firewall/raw action=notrack — it does NOT match FastTrack flows. FastTrack is a separate fast-path that keeps flows in conntrack but bypasses mangle. Never combine fasttrack-connection with mangle-based routing marks on the same traffic — mangle marks are not applied to fasttracked packets.
NAT Patterns
Layer7 Protocol (L7)
L7 matches unencrypted payload content with a POSIX regex — CPU-intensive, use sparingly:
L7 alternation: (a|b|c) is correct. (a)|(b)|(c) has POSIX ERE operator precedence bugs — the middle branch (b) matches anywhere in the stream, not anchored. Use grouped form with | inside parentheses only.
Common LLM Mistakes
| Mistake | Correct RouterOS behavior | |||||
|---|---|---|---|---|---|---|
Using priority= or rule weight | Rules are sequential — order is position, not weight | |||||
| Writing one rule per IP address | Use src-address-list= or dst-address-list= | |||||
remove [find dynamic=no] in scripts | Tag-based: remove [find comment~"prefix-"] only | |||||
Forgetting place-before= on accept rules | Default appends — accept rules below drops never fire | |||||
connection-state=new,established | Valid states: new, established, related, invalid, untracked | |||||
action=log or passthrough=yes stops evaluation | Non-terminal actions continue to next rule — a drop below still fires | |||||
| Combining fasttrack + mangle routing marks | fasttrack bypasses mangle — pick one or the other | |||||
| `(a)\ | (b)\ | (c)` alternation in L7 regexp | Use `(a\ | b\ | c)` — grouped form inside one set of parentheses | |
| One firewall rule per interface | Use in-interface-list= with a named interface list | |||||
IPv6 traffic handled by /ip/firewall | IPv6 uses a separate /ipv6/firewall — rules do not apply cross-protocol |
Additional Resources
Related skills:
routeros-fundamentals— RouterOS CLI syntax, REST API, scripting basicsrouteros-hotspot— hotspot chain interaction with firewall, walled garden
Reference files in this skill:
- references/mangle-routing.md — policy routing with routing marks,
hotspot=authmatcher - references/dos-protection.md —
psd,tarpit,connection-limitDoS patterns
MCP tools:
rosettaMCP —/ip/firewallcommand tree inspection (routeros_search,routeros_get_page)
MikroTik docs:
- Firewall Filter — filter chain reference
- NAT — NAT actions reference
- Connection tracking — connection states
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingrouteros-firewall/SKILL.md
Popularity
- Repository stars
- 81
- Repository forks
- 18
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/tikoci/routeros-skills/routeros-firewall)