I am in the habit of taking pictures to document the progression of works, so here it is (9 June 2025 8:00 Zulu):

Moved to Excel (which while being a little poorer on the graphic side is easier for managing this kind of stuff, inkscape - possibly my fault - had a couple issues with connectors' arrows and grid snapping).1 Incoming Packet
2 raw PREROUTING
3 Connection (state) tracking
4 mangle PREROUTING
5 Is src addr router's own?
6 mangle INPUT
7 filter INPUT
8 nat (srcnat) INPUT
9 to router's internal process
10 nat (dstnat) Prerouting
11 Routing Lookup
12 Is dst addr router's own?
13 mangle FORWARD
14 filter FORWARD
15 packet generated by router
16 Initial Routing Lookup
17 raw OUTPUT
18 Connection (state) tracking
19 mangle OUTPUT
20 nat (dstnat) OUTPUT
21 Final Routing Lookup
22 filter OUTPUT
23 mangle POSTROUTING
24 Is dst addr router's own?
25 nat (srcnat) POSTROUTING
26 Outgoing Packet
2018-09-01: Reflects that localhost-sourced/destined packets will not traverse the nat table’s PREROUTING/POSTROUTING chains, respectively. Thanks to commenter Binarus for the pointer.
Phil Hagen
September 1, 2018 at 6:32 am
Aha – I see what was meant before and I appreciate the input. I’ve updated this to reflect two differences when handling localhost-to-localhost packets. (Note that the nat/POSTROUTING chain is not used for packets destined to localhost either.)
$ ip route list table main
[...]
192.168.80.0/24 dev enp4s0 proto kernel scope link src 192.168.80.229 metric 100
[...]
$ ip route list rable local
[...]
local 172.18.0.1 dev br-6c15e4ab1bf0 proto kernel scope host src 172.18.0.1
[...]
Maybe "packet from router (itself)" or "packet to router (itself)" would be correct?
Thanks again for highlighting this.Maybe "packet from router (itself)" or "packet to router (itself)" would be correct?
I find this better too. And actually the outgoing line from the Yes branch of #24 doesn't need to go down to #26 and can instead loop up to directly enter #2. This would make the "loopback" explicit.
Is that "only" what you're trying to doI am only trying to make the IPTABLES flowchart lurker888 posted a link to at the same time more suited to Mikrotik while keeping it readable by IPTABLES experts AND make it understandable to the "masses" AND attempt to organize it visually in such a way that WHERE the settings are is evident (something that is usually not immediate in most flowcharts I have seen).
Well, let's hope it's not a big, beautiful job, eh?it's a beautiful job you're doing.
EDIT:Attachment removed see below for newer version1 Incoming Packet
2 raw PREROUTING
3 Connection (state) tracking
4 mangle PREROUTING
5 src addr=self? (loopback)
6 mangle INPUT
7 filter INPUT
8 nat (srcnat) INPUT
9 to router's internal process
10 nat (dstnat) Prerouting
11 Routing Lookup
12 dst addr=self? (loopback)
13 mangle FORWARD
14 filter FORWARD
15 packet generated by router
16 Initial Routing Lookup
17 raw OUTPUT
18 Connection (state) tracking
19 mangle OUTPUT
20 nat (dstnat) OUTPUT
21 Final Routing Lookup
22 filter OUTPUT
23 mangle POSTROUTING
24 dst addr=self? (loopback)
25 nat (srcnat) POSTROUTING
26 Loopback interface
27 Outgoing Packet
If "pure white" is OK (even with 50% alpha blend) and people using dark mode won't get a fit by looking at it, I would prefer it, it is how traditionally (after papyrus and parchment) we are used to read things.* On the background color. I think that at least for the default png version legibility should be primary (come on, we all know that will be the one that's going to be viewed the most - people are lazy) For me the current color works in this regard, but I'm sure someone with more experience can come up with something better. For web publishing white with 50% alpha is a common choice - it ensures legibility on all backgrounds. (I know this is not the time for this coming-out, but a looong time ago I used to do publishing quality technical illustrations, so I might have to polish off my toolbox... but whether I do it depends very much on how much free time and beer I have on my hands.)
I thought that src addr and dst addr were vital to make it adapted to Mikrotik jargon, let's wait what other people think, in any case I "need" a question mark as it is a question (to which you can answer Y or N) .* With respect to the src-addr/dst-addr thing, especially with the "(loopback)" added, I would be inclined to just put "from self (loopback)" and "to self (loopback)" respecively. I think this is not inaccurate anymore, and with "loopback" added (in both wording and the actual path) there is no confusion anymore, even to the most casual reader.
No, you don't* I understand not wanting to cross path lines, but I think "loopback" might fit tidily in the middle. Of course this is a matter of aesthetics.
Yep that is not a problem. I wonder if "Mikrotik naming" or "Mikrotik configuration naming" or something else.* I would make it clear(er) in the top-left "Mikrotik" that it's the "Mikrotik naming". There's no shortage of space there. (I know this is paranoia, but it occurs to me that someone might think this is actually Mikrotik documentation, when it's documentation *about* Mikrotik.)
Yep, also visually (with my art director hat on) I am not at all satisfied of the central (now pale yellow) box, or of the text in it. I could remove the forum address (and thus make the titles more proportionally evident and the box more adequate to two lines of text) and use the bottom left corner for the forum address, date, version, whatever in smaller characters.* It would be nice to put some sort of date (as a version number) in the title caption of the thing. For now, I would also add something like "beta". Having the date could make the usage of these diagrams mush nicer, should they ever be updated.
Oww, come off it, it is not such a precious resoource that will become viral, the people actually interested in this (all 42 of them) can get it from this thread just fine.* It would also be nice if someone could offer a space in the corner of some webserver for perma-hosting this. This is of course jaclaz's diagram, but if my opinion were to count (hint: it really doesn't), I'd insist on something that is not some arm of a cloud service / non-ad supported / not tracking its users. I might offer such a space but that would actually require installing and configuring a web server...
Right now what I am doing is:* As a last potential step - if jaclaz really has the time - I would suggest creating a low-res (web viewing) and high-res version. Also in some situations b&w is strongly preferred. When it's completed, I'd be inclined to use this in printed documentations and there b&w and high-res still dominate.
I don't care about the majority, it is not democracy, but you'll have to defend your opinion in front of the Court (myself)* I sense that this is not in agreement with the majority opinion here - which is find, thats why it's called the majority opinion. But I'd use the same style box for the loopback as for the incoming/ougoing packet. However not-labeled these things are, they all represent interfaces, and in my time doing illustrations (and also teching) I observed that the "impression" that illustrations convey sometimes sick with people for a surprisingly long time, even when what exactly it is they convey is unclear to them initially. If it were totally up to me, I's actually separate the loopback into two, "to loopback" and "from loopback" places right next to each other, to convey that the packet actually exits netfiler, and then is reinjected. You wouldn't guess from the amount of text I devote to this, but this is a really minor point.
I tend to use my Careware license for this kind of stuff:EDIT: Also, wherever this ends up being hosted, it really should be accompanied by a copyright notice. I usually just say it's fine to reproduce anywhere, but it's jaclaz's product, so obviously the decision rests there. There's also the GNU Free Documentation License (GFDL) and various CC ones.
I think that png is better in resizing/adapting to various resolutions, and it supports Alpha channel just fine.Very minor, but eventually, if you use GIF with Alpha channel that might allow better support for dark-mode, to avoid the hideous sand color background.
I saw PDF here... Not the expert here and don't know tool, but I meant the setting the transparency color, and leave alpha along. 50% look bad in both light and dark modeI think that png is better in resizing/adapting to various resolutions, and it supports Alpha channel just fine.Very minor, but eventually, if you use GIF with Alpha channel that might allow better support for dark-mode, to avoid the hideous sand color background.
In this I recant, for it was me that led you astray. No, seriously, this was a simplification gone too far. As I have explained, for the src addr part actually the input interface is inspected, for the dst address part, the appropriate ("local") flag for the route selected is consulted. I think "from self (localhost)" is a statement that can have a question mark appended and be rightly considered to have a Y/N answer. (Or in its statement form has a property of "is this true? (in this case)")I thought that src addr and dst addr were vital to make it adapted to Mikrotik jargon, let's wait what other people think, in any case I "need" a question mark as it is a question (to which you can answer Y or N) .
That's exactly what I mean by preferences - we all have our own. With regard to your work you have no one to report toNo, you don't, the whole point is to not cross path lines or use (stupid) on-page connectors. People should be able to use it to play a sort of goose game on it without jumping over this or that.
Yep. Thanks!Yep that is not a problem. I wonder if "Mikrotik naming" or "Mikrotik configuration naming" or something else.* I would make it clear(er) in the top-left "Mikrotik" that it's the "Mikrotik naming". There's no shortage of space there. (I know this is paranoia, but it occurs to me that someone might think this is actually Mikrotik documentation, when it's documentation *about* Mikrotik.)
Okay. Let's hope no one's interestedOww, come off it, it is not such a precious resoource that will become viral, the people actually interested in this (all 42 of them) can get it from this thread just fine.* It would also be nice if someone could offer a space in the corner of some webserver for perma-hosting this. This is of course jaclaz's diagram, but if my opinion were to count (hint: it really doesn't), I'd insist on something that is not some arm of a cloud service / non-ad supported / not tracking its users. I might offer such a space but that would actually require installing and configuring a web server...
F*ing awesome.I don't care about the majority, it is not democracy, but you'll have to defend your opinion in front of the Court (myself)* I sense that this is not in agreement with the majority opinion here - which is find, thats why it's called the majority opinion. But I'd use the same style box for the loopback as for the incoming/ougoing packet. However not-labeled these things are, they all represent interfaces, and in my time doing illustrations (and also teching) I observed that the "impression" that illustrations convey sometimes sick with people for a surprisingly long time, even when what exactly it is they convey is unclear to them initially. If it were totally up to me, I's actually separate the loopback into two, "to loopback" and "from loopback" places right next to each other, to convey that the packet actually exits netfiler, and then is reinjected. You wouldn't guess from the amount of text I devote to this, but this is a really minor point..
https://www.quotes.net/mquote/65590
In natural language usage, yes, interface has a meaning of something I can plug something into. In terms of the netfilter framework, interface has a specific meaning of what's in the kernel called a netdev. Loopback is such. In that it's somewhat simplistic in that it returns whatever it receives makes it no less so.If an interface has not a RJ45, a SFP socket or an antenna, it is a "different" interface.
In any case NO interface (exception made for the "different" loopback) has been cited (nor harmed) in the making of the diagram, we have Incoming and Outgoing Packets (and that a packet has a different symbol from an interface is a self evident truth).
Now (since it is anyway "different") the idea of dividing the loopback interface in two seems to me a nice one.
Also I would like *somehow* add that this interface is exposed as (lo) in newish RoS.
SureWhy not publish plain svg?
I thought that src addr and dst addr were vital to make it adapted to Mikrotik jargon, let's wait what other people think, in any case I "need" a question mark as it is a question (to which you can answer Y or N) .* With respect to the src-addr/dst-addr thing, especially with the "(loopback)" added, I would be inclined to just put "from self (loopback)" and "to self (loopback)" respecively. I think this is not inaccurate anymore, and with "loopback" added (in both wording and the actual path) there is no confusion anymore, even to the most casual reader.
Yep, I'll fix the /ip firewall filter.
The fun thing is that I didn't use (AFAIK) a gradient, anyway it is far more dark *everywhere* than I would have expected.
Maybe the 50% opacity is too transparent for your darkmode
I'll check the gradient (if any) and try with 70% opacity
EDIT: files in post #37 changed. See if it is now better in dark mode.
P.S. It must be something connected to the way dark mode works, the 70% (Gray 2.5%=white) Opacity should be more light than 50%, (but it is not in a browser I have).
But if I open the image in a new tab, the colour becomes lighter (still darker than the original, but a gray light enough to be readable)
Another attempt, 70% Gray 2.5%=White
Flowchart_beta01_W70.svg.png
Try again I re-made the background for the image in post #39.There will always be something cosmetic left to do, but that's what I would call basically (almost) done. Thanks for the not insignificant effort!
For me at least the latest 100% opaque is shown as 100% transparentIs there this much difference between browsers? Can the page's css interact with it somehow?
Yep, I'll fix it.Shouldn't it say "chain: postrouting" in right top corner?
Good, probably I had some wrong settings in #37, though if you open the file in #39 on another window, background should become much lighter.This version now looks fine on my phone(the one that you edited on #37 is however VERY dark).
The first thing to do when encountering issues is to stop digging! ;-P<placeholder post for the final version - once ready>
I am in the habit of taking pictures to document the progression of works, so here it is (9 June 2025 8:00 Zulu):
photo1.jpg
![]()
The first thing to do when encountering issues is to stop digging! ;-P
anav could be the one top left, depressed/frustrated as in this thread he cannot suggest VLANs nor "drop all else" as last rule.There is still a few guys in the pic without name. You can add some comments and one will be named anavThe first thing to do when encountering issues is to stop digging! ;-P![]()
I (and I'm sure others) would indeed find it helpful to have "common" packet flow scenarios run through the flowchart. This process would be an educational one (to help better understand packet flow and the control thereof within ROS) as well as possibly a check on the the validity and accuracy of the flowchart. I was reluctant to ask/suggest because my scenarios would be of the extremely simple type.I asked if it would be useful to outline some common packet flow scenarios
Even if the second (reply/response) packet is not the SAME one, it wouldn't exist (IF it exists) without the first (incoming) one.Well, not exactly. 1->9 is the flow for the initial packet client->router; 15->27 is for the response packet router->client. They are different packets - that the ssh server (daemon) produced the second packet in direct response to the first is not a firewall question.
E.g. a DNS request may trigger a response, or the DNS server might first contact an upstream, and only upon receiving *its* answer would it respond to the client, etc. - so it's entirely dependent on what the given service decides to do.
Still, if anav, whom - while maybe not a qualified network engineer - definitely has some little familiarity with Mikrotik firewall settings had this doubt, think of what a newcomer would think/believe..I don't think that's necessary (something describing the "link" between #9 & #15), because for a packet destined for the router, its lifetime ended at #9. The "flow" of that packet has finished there.
Let's say we add something explaining the fact that after a packet has reached #9, some kind of new packet would be originated at #15 in response (even though that's not true in all case, when a WireGuard handshake packet using the wrong key it sent to the router for instance, absolutely no response packet will be produced), then we would also need to write something explaining that after a packet has been sent to #27, something in response might arrived at #1 (produced by remote devices), or not. But we can agree that this is completely unnecessary and doesn't need to be mentioned on the flow chart. Which means the possible "link" between #9 and #15 also doesn't need to be explained neither.
In the old version of the chart, there were the case where the same packet going out of #27 can end up going back to #1 (being the same packet), and that was the router-loopback case, but that specific flow now has its own path through #26 and requires no further footnote/explanation.
To me at least "qualified network engineer" carries not only no weight, but no meaning. What's the criterion anyway? They have a degree? They're paid to do it? Most people who have some relevant degree/certification and are paid to do it know *way* less than @anav. (Quite often so much less, that it's sad and horrifying.) Okay, rant over.Still, if anav, whom - while maybe not a qualified network engineer - definitely has some little familiarity with Mikrotik firewall settings had this doubt, think of what a newcomer would think/believe..
*sobs quietly*Anyway, yours and lurker888's objections are overruled.![]()
I actually like this. It's definitely a step away from the sterile view of presenting only the kernel subsystem. But it could very well be way easier to understand.One way to make the traffic to and from the router more visual might be to add a symbol right in the middle of the diagram that represents the router itself and its different services.
Yes.Are you talking about something like the gray circle (with services) in my suggestion, or are you referring to a completely different approach?
Only little problem being that we don't have "a box labeled "local processes" and an arrow pointing to it."I was referring to something very much like yours, with the gray circle. My suggestion was to basically just have the gray circle, and give the things that are now rounded rectangley less focus. Simply because it's pointless to write "to local process", when we have a box labeled "local processes" and an arrow pointing to it...
Make an exact list of those services.I would only suggest that instead of the assorted kitchen utensils, actual text could be included, like "services", and while I'm a bit "put off" by it, I think actually including some well-known examples, such as "DNS, Winbox, SSH" there would certainly help in making the idea immediately recognizable. (Maybe with small letter?) Maybe these labels don't deserve their own box? Maybe they should be in some sort of "cloud" symbol to show that they are sort of indefinite (or a loose assortment), at least from the POV of the diagram.
Now you're just being cruel...Only little problem being that we don't have "a box labeled "local processes" and an arrow pointing to it.", nor we have written anywhere (on the flowchart) "to local process"
.
We do have a box labeled "to router's internal process" with an arrow pointing to it, though.
I think as a symbol something like this is fine.Make an exact list of those services.
I have about six lines available in Excel that should be enough for about 6 or so (maybe a few more if three or four letters) of them in 10 points characters (they will become roughly 8 points in the final svg/png A3 version), small but still readable:
This post does self-destruct within 5 seconds, doesn't it ?Your mission, should you accept it, ...
Naah, it uses Mikrotik v 6 date/time format, but runs on v 7 so it will self-destruct at a random instant between last week and next year.This post does self-destruct within 5 seconds, doesn't it ?![]()
Okay:Your mission, should you accept it, is to list a number (no less than 6, no more than 12) of the most commonly used *things*, those that can be considered exemplary for the concept to be easily graspable, in an order similar as much as possible as their usage in the real world.
You must be joking6. detect internet
You're right actually. I've just been skared by the multiwan routing of the tunnel@Amm0: Actually Wireguard is fully covered.
I don't understand, but the idea of building something is to change it when it doesn't do what it should do.@jaclaz: I'm sorry to notice this only at this late stage, but logically reading your diagram (I mean the horizontal and vertical arrows at the left and top) it's not easy to deduce that no. 10 would be used in Mikrotik as "nat add chain=dstnat" (not chain=postrounting), and similarly with no. 25. Is this intentional?
Good.EDIT: That graphic with the floating services actually makes a lot of sense.
Yup, some "overlays" with connection arrows (in "Dude terms", "links") might be one future approach@Amm0: Once the diagram is finished, it’s time to start adding different use cases. I’m thinking maybe 8–10 examples should be enough to cover most of the common scenarios. [...]
Yup, I kinda think so. I do find the MT's packet flow useful — but it does not provide the initial overview of how it relates to actual configuration, nor provide an "overview".Feels like this could turn into something really useful now that we can use numbers as clear references in the packet flow.
@jaclaz; Yeah, looking good!
Minor, again, the "fat arrow" things are not process. Maybe use rounded corners label boxes with the arrows, or just put the text in arrow without any box. Just so they are even more visually distinctive from the "inner" boxes.Or only change the purple fat arrows on the left?
Or both?
The problem stems from the fact that Mikrotik renamed "nat PREROUTING" to "/ip firewall nat add chain=dstnat" and "nat POSTROUTING" to "/ip firewall nat add chain=srcnat". This is not terrible naming, btw. And yes, they renamed just these two, in the other tables (mangle, raw) the chains were left as pre/postrouting.I don't understand, but the idea of building something is to change it when it doesn't do what it should do.
Do I need to add a chain? Or two? at the top?
Or only change the purple fat arrows on the left?
Or both? actually one of the things that I don't like of the current diagram is the duplication of the purple /firewall nat, if there is a way to avoid that I would be happy, even if it implies adding chains, sections or whatever and complicating the path of links..
It is not difficult with the current base to provide unambiguous instructions in the form:
box#-X-Y-text
Example:
6-chain=input-/ip firewall mangle-mangle INPUT
or the full/partial "real" syntax (or "MikroTtik configuration naming") like "nat action=dstnat"@jaclaz, just a minor detail: shouldn’t the text in the purple "nat" boxes to the left be something like “/ip firewall srcnat” and “/ip firewall dstnat” instead of just “/ip firewall nat”?
In the next release, I will add something *like* this.
Hopefully giving the impression of "a bunch of stuff floating inside the router".![]()
Mt_services.JPG
I think CGGXANNX at least deserves to be given no. 6, and also to replace SSH if he thinks there's a better example.
Not shown, but "ping" / ICMP be in same category since the kernel does some work there.Yep. DHCPv4 shouldn't be mentioned.
We have 4 (four) purple items.The problem stems from the fact that Mikrotik renamed "nat PREROUTING" to "/ip firewall nat add chain=dstnat" and "nat POSTROUTING" to "/ip firewall nat add chain=srcnat". This is not terrible naming, btw. And yes, they renamed just these two, in the other tables (mangle, raw) the chains were left as pre/postrouting.
I am not following you, in terminal do you have:@jaclaz, just a minor detail: shouldn’t the text in the purple "nat" boxes to the left be something like “/ip firewall srcnat” and “/ip firewall dstnat” instead of just “/ip firewall nat”?
The Mikrotik syntax in the row/column headings definitely suggests that a valid command can be assembled when reading them in the Y-X direction (the reverse of what you listed.)We have 4 (four) purple items.
#8
#10
#20
#25
They are currently (and wrongly) placed (#-X-Y-text) as follows:
8-chain=input-/ip firewall nat - nat (srcnat) INPUT
10-chain=prerouting-/ip firewall nat-nat (dstnat) PREROUTING
20-chain=output-/ip firewall nat - nat (dstnat) OUTPUT
25-chain=postrouting-/ip firewall nat-nat (srcnat) POSTROUTING
How should they be placed (in theory)?
(If I understand correctly, this is the solution suggested by CGGXANNX)
As requested:I will try again.
1. In which chain= should 8 go?
2. In which chain= should 10 go?
3. In which chain= should 20 go?
4. In which chain= should 25 go?
I am asking 4 (four) questions, numbered 1 to 4.
I expect 4 (four) answers, numbered 1 to 4.
Any other answer - particularly if partial - only confuses me.
As requested:
1. #8 chain=input
2. #10 chain=dstnat
3. #20 chain=output
4. #25 chain=srcnat
For all the boxes:
#2 chain=prerouting
#4 chain=prerouting
#6 chain=input
#7 chain=input
#8 chain=input
#10 chain=dstnat (*)
#13 chain=forward
#14 chain=forward
#17 chain=output
#19 chain=output
#20 chain=output
#22 chain=output
#23 chain=postrouting
#25 chain=srcnat (*)
(*) - these two are the only ones named different than iptables
[admin@xxx] > /ip firewall nat add chain= <<TAB>>
dstnat input output srcnat
Very goodHowever... if you take a pristine 7.18.2 and gothey're there. I sometimes (very-very rarely) use these chains, and I have verified that they are fully functional and correctly available.Code: Select all[admin@xxx] > /ip firewall nat add chain= <<TAB>> dstnat input output srcnat
Well, I really wasn't aware that it was ever not available. Again, I use it only on special occasions.Very good..
The quick table I posted I extracted from terminal command line of v6.49.17, so *something* must have been changed in *some version* of 7.
It will be important to find out which one as the flowchart will apply from that version onwards (and we can make a footnote about chains input and output not being visible in v6 in /ip firewall nat)