A Python-based simulator for MikroTik RouterOS firewall configurations (specifically tested against CCR1036/Tilera exports). This tool allows you to trace packet flow through Filter and NAT tables, validate rules against real-world logs, and debug complex stateful configurations.
-
Multi-Table Support: Simulates
filter,nat, andmangletables. -
Full Chain Logic: Correctly models
input,output,forward,prerouting,postrouting,dstnat, andsrcnatchains. -
Stateful Tracking (Conntrack): Maintains a connection table with
$O(1)$ lookups to handleestablishedandrelatedtraffic. -
Automatic NAT: Handles
src-nat,dst-nat,masquerade,redirect, andreverse-natfor reply packets. -
Smart Interface Detection: Automatically determines
in-interfaceandout-interfaceby parsing/ip addressand/ip routesections. -
Address List Integration: Supports built-in address lists and external list files (e.g.,
tilera.address-list.2). -
Protocol Support: Deep matching for
tcp,udp, andicmp/icmpv6(including type/code matching). -
Mangle Support: Support for
mark-packet,mark-connection, andmark-routingactions. -
Verification Tool: Batch-test the simulator against
drop.logto ensure parity with real hardware.
# No external dependencies required (uses standard library)
git clone https://github.com/ffzg/tilera-fw-simulator.git
cd tilera-fw-simulatorpython3 simulate_firewall.py --src 10.60.0.92 --dst 8.8.8.8 --proto udp --dport 53python3 simulate_firewall.py --src 193.198.212.229 --dst 193.198.212.1 --proto tcp --dport 8291 --verbosepython3 verify_simulator.py --limit 500Verified 100% parity against the first 500 IPv4 entries of production drop.log.
Supports dual-stack configurations with full IPv6 firewall and Mangle table simulation.
- Single-pass RSC configuration parsing.
-
$O(1)$ Connection Tracking (Conntrack). - Filter, NAT, and Mangle table simulation.
- Automatic Interface/Route lookups.
- Response testing by default.
- Untruncated rule output for better debugging.
- IPv6 Support: Full dual-stack simulation.
- Mangle Table: Implementation of
/ip firewall mangleand routing marks. - Advanced Matchers:
content,tcp-flags, andpacket-size. - Layer 2 Simulation: Basic support for
/interface bridge filter.
- Interactive Mode: A "What-If" shell for real-time packet tracing.
MIT