I know linux has 3 built-in tables and each of them has its own chains as follow:
FILTER: PREROUTING, FORWARD, POSTROUTING
NAT: PREROUTING, INPUT, OUTPUT, POSTROUTING
MANGLE: PREROUTING, INPUT, FORWARD, OUTPUT, POSTROUTING
But I can't understand how they are traversed, in which order, if there is. For example, how are they traversed when:
- I send a packet to a pc in my same local network
- when I send a packet to a pc in a different network
- when a gateway receives a packet and it has to forward it
- when I receive a packet destinated to me
- any other case (if any)
nat/INPUT
andfilter/INPUT
in the source code and the Wikipedia diagram is definitely wrong. – Andrew Bate Oct 06 '21 at 22:52filter/INPUT
andnat/INPUT
. Having looked at the netfiler source code, I believe that Phil Hagen's diagram is correct. – Andrew Bate Oct 06 '21 at 23:02