elevation
13 hours ago
This place needs more of this kind of documentation.
I failed to use IP tables for years. I bought books. I copied recipes from blog posts. Nothing made sense, everything I did was brittle. Until I finally found a schematic showing the flowchart of a packet through the kernel, which gives the exact order that each rule chain is applied, and where some of the sysctl values are enforced. All of a sudden, I could write rules that did exactly what I wanted, or intelligently choose between rules that have equivalent behaviors in isolation but which could have different performance implications.
After studying the schematic, every would just work on the first try. A good schematic makes a world of difference!
HotGarbage
12 hours ago
Was it this one? https://en.wikipedia.org/wiki/File%3aNetfilter-packet-flow.s...
PunchyHamster
4 hours ago
It is also worth mentioning TRACE target that will dump to logs which exact rule the packet hit, it's invaluable big firewalls.
Koffiepoeder
12 hours ago
Can you share the diagram? Would love to become iptables-enlightened.
elevation
12 hours ago
Eventually I used more detailed diagrams, but this one was like a lightbulb going off:
https://www.frozentux.net/iptables-tutorial/images/tables_tr...
I couldn’t find one that annotated where sysctl configurable were shown. But this is a useful annotation, even if it’s an exercise for the reader.
eptcyka
11 hours ago
It is time to be nftables enlightened instead.
VTimofeenko
11 hours ago
Similar diagram, right in nftables wiki:
https://wiki.nftables.org/wiki-nftables/index.php/Netfilter_...
Arch-TK
10 hours ago
It's more of a netfilter (the thing behind iptables and nftables) diagram rather than just iptables.
If you know how iptables maps to that diagram you are very likely to be able to quickly understand how nftables does too.
eptcyka
7 hours ago
Sure, but we really shouldn’t be encouraging the use of iptables in 2025.
mmh0000
an hour ago
That's not realalistic for most of the Linux world.
Soooo many systems are still using iptables even though we "should" be using nft everywhere.
If you're going to be a Linux Sys/Net Admin today, you need an understanding of both systems.
jcynix
11 hours ago
Besides the diagram you'll find tutorials on https://www.frozentux.net/category/linux/iptables/ too.
And at http://www.easyfwgen.morizot.net/ there's an old, but still useful generator for an iptables setup. That should help to understand iptables.