What order do RouterOS firewall and NAT chains actually run in?
For a packet crossing the router — not one addressed to the router itself — the order is fixed: RAW prerouting, connection tracking, mangle prerouting and destination NAT; then the routing decision; then mangle forward and filter forward; then mangle postrouting, source NAT and the queues. This map draws the eight stages that set cost and visibility; mangle postrouting and the queues aren't drawn. A packet addressed to the router branches off at the routing decision into its own input chain instead, and this map doesn't follow that branch.
Why drop a flood in RAW instead of the filter chain?
A drop in RAW happens before the router opens a connection-tracking entry for that packet, so it costs almost nothing. The identical drop in the filter chain happens after conntrack has allocated that entry and the packet has been carried through mangle and NAT, which makes filter the most expensive place to drop it. RAW sees only the bare packet, with no connection state, so it suits traffic you can refuse on sight. Drop at the earliest stage that can still match the traffic.
Why does destination NAT run before the routing decision?
Because RouterOS needs the real destination settled before it can route on it. Dst-nat sits in the prerouting chain, ahead of the routing decision — so when a port-forward rewrites where a packet is going, the router then routes on that new address. That ordering is what makes a port-forward actually reach an inside service instead of just relabeling a packet that's already been routed elsewhere.
Do my forward-chain filter rules see the real source address, or the masqueraded one?
The real one. Filter (forward) runs before source NAT, so your accept/drop rules judge the actual client address, not whatever address will replace it on the way out. Source NAT — masquerade — runs afterward, in postrouting; from there on, the outside world sees only the router’s own address, never the host behind it.
What's the difference between mangle prerouting and mangle forward?
Which side of the routing decision they sit on. Mangle prerouting runs before the router has chosen a route, so it's where you mark a connection to steer the routing decision itself — policy routing. Mangle forward runs after the route is already picked, on traffic the router has already committed to sending out a specific interface, which makes it the right place to tag traffic for the queue it's about to hit.
Should I mark the connection or the packet?
Mark the connection when the mark has to follow the whole flow. Connection tracking keeps a connection mark on the connection itself, so a mark set on the first packet applies to every packet after it, in both directions — the mechanism policy routing relies on for the return path. A packet mark lives on one packet: later chains and queues still see it on that packet's way through the router, but the next packet starts clean. The usual pattern uses both — mark the connection once, then set packet or routing marks from the connection mark.
Where do the input and output chains fit into this map?
Off to the side. This diagram is the forward path only — a packet passing through your router. A packet addressed to the router itself branches off right after the routing decision into its own chain: mangle input, then filter input. A packet the router originates runs mangle output and filter output before it ever reaches postrouting. Both are real, documented chains — just not the ones this map draws.
Why can't I reach anything over an IPsec road-warrior tunnel with my normal LAN rules?
Because IPsec traffic has no interface of its own. After decryption it surfaces on the physical interface it arrived on (for a road-warrior, usually your WAN), and a default-deny forward chain drops untrusted WAN traffic as designed. People blame the tunnel first, but the tunnel is fine (field). Keep the WAN closed and accept the decrypted traffic by matching its IPsec policy, ahead of the WAN drop. RouterOS's default firewall ships that accept rule, so the problem shows up in hand-built rulesets.
Why does connection tracking run after RAW instead of before it?
So RAW can act before the router has spent anything on the packet. RAW prerouting is the earliest point where you can act on an arriving packet — it runs before conntrack allocates a tracking entry, which is exactly why a drop there is nearly free. That's the RAW table's stated job: drop or bypass traffic before connection tracking, to spare the CPU. Flip the order and every packet would cost a tracking entry before RAW ever got a chance to say no.