Skip to contentSkip to conversation

magle, filter & FORWARD

DISCUSSION Kevin D. White 4 participants 5 messages Jun 2, 2004 – Jun 3, 2004

lore
Share & tools
lore
#0 lore raw

Ok, now that I have made the major mistakes and they are out of the way, let me try this.

Netfilter is made up of 5 subsystems, Pre-routing, Input, Forward, Output and Post-routing. These subsystems are governed by three tables, nat, magle, filter. The elements of these tables have the following characteristics. First there is a 'hook' or subsystem identifier (i.e. PREROUTING, INPUT, FORWARD, etc), then there is a condition and finally there is an Action/Target. All received packets begin in the Pre-routing subsystem, the Pre-routing subsystem accesses the nat table and looks for all it's hooks (all elements with PREROUTING). Then the same is done with the mangle table. A routing decision is made, and the packet would either move into the Input subsystem or the Forward subsystem were the tables for those subsytems would be accessed and so on. All packets end up in the Post-routing subsystem before leaving an interface.

I am intentionally ignoring user created hooks.

__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/

#1 lore raw

At first, sorry for any confusion I created, but sadly I would have to agree with Dick St.Peters about the definition mistake I made: Chains still are what they were with ipchains.

Trouble is that there are several objects involved:

hooks    Place in the network-subsystem where packets are matched
tables   Combination of chains with similar purpose
chains   List of rules applied in turn at a give packet
rules    Packet matching and handling
Quoted 5 lines · Kevin D. White

Ok, now that I have made the major mistakes and they are out of the way, let me try this.

Netfilter is made up of 5 subsystems, Pre-routing, Input, Forward, Output and Post-routing.

Correct, 5 hooks in the networksubsystem where chains can be attached.

Quoted 3 lines

These
subsystems are governed by three tables, nat, magle, filter.

At these points one or more tables filled with chains are attached. These tables are for different purposes: filtering, Address translating and mangling of packetfields.
Initially each table contains 1 chain with a similar name as the 'hook' where this table is attached.
In the 'nat' table at the POSTROUTING hook, there is a chain called POSTROUTING.

Quoted 5 lines

The elements of these tables have the
following characteristics. First there is a 'hook' or subsystem identifier (i.e. PREROUTING, INPUT, FORWARD, etc), then there is a condition and finally there is an Action/Target.

No, it's not 'hook' nor subsystem identifier, but the name of the chain this rule is attached to:
Parent chain, condition and target.

iptables -t nat -A PREROUTING -s 192.168.4.6 -j ACCEPT -------------------p. chain--- Condition ---- Target

Quoted 4 lines

All received packets begin in the Pre-routing subsystem, the Pre-routing subsystem accesses the nat table and looks for all it's hooks (all elements with PREROUTING).

Thus this will become:
All received packets begin at the PREROUTING hook, where the connected 'nat' table is being checked by accessing the primary chain called PREROUTING. This chain is checked for matching rules.

Quoted 2 lines

Then the same is done
with the mangle table.

Next the mangle table is checked for the PREROUTING chain.

Quoted 7 lines

A routing decision is made,
and the packet would either move into the Input subsystem or the Forward subsystem were the tables for those subsytems would be accessed and so on. All packets end up in the Post-routing subsystem before leaving an interface.

This is correct.

Quoted 2 lines

I am intentionally ignoring user created hooks.

They are user created chains which can be stored in each table and function as a new target:
iptables -t mangle -N test
iptables -t mangle -A test -j MARK --set-mark 3
iptables -t mangle -A PREROUTING -s 192.168.4.6 -d 192.168.4.7 -j test

Quoted 8 lines

__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/

#2 lore raw
Quoted 5 lines · --- Ludo Stellingwerff

At first, sorry for any confusion I created, but
sadly I would have to
agree with Dick St.Peters about the definition
mistake I made: Chains
still are what they were with ipchains.

No problem, this is a public mail list and the fact your tring to help gives you instant forgiveness :) It's a good thing that there are people like Dick who mantain the integrity of archives for an open discussion! Way to go Dick!

Quoted 7 lines

Trouble is that there are several objects involved:
hooks Place in the network-subsystem where
packets are matched
tables Combination of chains with similar purpose
chains List of rules applied in turn at a give
packet
rules Packet matching and handling

Yes, my questions seem to lean towards the inner workings of Netfilter and is not so much about how to do something.

Quoted 10 lines · Kevin D. White
Quoted 1 line

Ok, now that I have made the major mistakes and

they

Quoted 4 lines

are out of the way, let me try this.

Netfilter is made up of 5 subsystems, Pre-routing, Input, Forward, Output and Post-routing.

Correct, 5 hooks in the networksubsystem where
chains can be attached.

phew!

Quoted 5 lines
Quoted 2 lines

These
subsystems are governed by three tables, nat,

magle,

Quoted 1 line

filter.

Quoted 11 lines

At these points one or more tables filled with chains are attached.
These tables are for different purposes: filtering, Address translating
and mangling of packetfields.
Initially each table contains 1 chain with a similar name as the 'hook'
where this table is attached.
In the 'nat' table at the POSTROUTING hook, there is a chain called
POSTROUTING.

Great! Two chains called FORWARD with different rules, located in different tables and used by the Forward subsystem.

Quoted 14 lines
Quoted 2 lines

The elements of these tables have the
following characteristics. First there is a

'hook' or

Quoted 1 line

subsystem identifier (i.e. PREROUTING, INPUT,

FORWARD,

Quoted 1 line

etc), then there is a condition and finally there

is

Quoted 1 line

an Action/Target.

No, it's not 'hook' nor subsystem identifier, but
the name of the chain
this rule is attached to:
Parent chain, condition and target.

Quoted 4 lines

iptables -t nat -A PREROUTING -s 192.168.4.6 -j
ACCEPT
-------------------p. chain--- Condition ----
Target

Good stuff! So the hook is a function in Netfilter that looks for chains that pertain to that particular subsystem, within the table that is attached.

Quoted 21 lines
Quoted 3 lines

All received packets begin in the Pre-routing subsystem, the Pre-routing subsystem accesses the nat table and looks for all it's

hooks

Quoted 1 line

(all elements with PREROUTING).

Thus this will become:
All received packets begin at the PREROUTING hook, where the connected
'nat' table is being checked by accessing the primary chain called
PREROUTING. This chain is checked for matching rules.

Quoted 2 lines

Then the same is done
with the mangle table.

Next the mangle table is checked for the PREROUTING
chain.

Quoted 3 lines

A routing decision is made,
and the packet would either move into the Input subsystem or the Forward subsystem were the tables

Quoted 8 lines

for

Quoted 2 lines

those subsytems would be accessed and so on. All packets end up in the Post-routing subsystem

before

Quoted 2 lines

leaving an interface.

This is correct.

phew!

Quoted 11 lines
Quoted 2 lines

I am intentionally ignoring user created hooks.

They are user created chains which can be stored in each table and
function as a new target:
iptables -t mangle -N test
iptables -t mangle -A test -j MARK --set-mark 3 iptables -t mangle -A PREROUTING -s 192.168.4.6 -d 192.168.4.7 -j test

Yes the rest is semantics, excellent.

Thank you very much Ludo, your a true scholar and a gentleman.

I'm very impressed with Netfilter and what it can do. If anyone needs a good replacement for what they are currently using, I will direct them to here.

Another big thanks goes out to Daniel, Justin and Dick!
:)

__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/

#3 lore raw
In reply to Kevin D. White
Quoted 9 lines · Kevin D. White

Netfilter is made up of 5 subsystems, Pre-routing, Input, Forward, Output and Post-routing. These subsystems are governed by three tables, nat, magle, filter. The elements of these tables have the following characteristics. First there is a 'hook' or subsystem identifier (i.e. PREROUTING, INPUT, FORWARD, etc), then there is a condition and finally there is an Action/Target. All received packets begin in the Pre-routing subsystem, the Pre-routing subsystem

Quoted 8 lines

accesses the nat table and looks for all it's hooks (all elements with PREROUTING). Then the same is done with the mangle table. A routing decision is made, and the packet would either move into the Input subsystem or the Forward subsystem were the tables for those subsytems would be accessed and so on. All packets end up in the Post-routing subsystem before leaving an interface.

Sorry, but the wording used above is incorrect and misleading.

Netfilter is *not* made of five subsystems and PREROUTING etc are definitely not subsystems of netfilter.

Quoted 1 line

I am intentionally ignoring user created hooks.

Just consider if you not ignore user created chains (not hooks): were they also netfilter "subsystems"?

Hooks, built-in chains, subsystems and tables are well covered in the howtos and the tutorials. Please read them.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#4 lore raw
Quoted 6 lines · Jozsef Kadlecsik
Quoted 4 lines · Kevin D. White

Netfilter is made up of 5 subsystems, Pre-routing, Input, Forward, Output and Post-routing. These subsystems are governed by three tables, nat, magle, filter. The elements of these tables have the

    ...
Quoted 4 lines

Sorry, but the wording used above is incorrect and misleading.

Netfilter is *not* made of five subsystems and PREROUTING etc are definitely not subsystems of netfilter.

Jozsef is correct, of course. In addition, recent kernels have a fourth table, the "raw" table, with its own PREROUTING and OUTPUT chains. Joszef is the originator of the raw table but apparently is too modest to mention it.

Quoted 2 lines

Hooks, built-in chains, subsystems and tables are well covered in the howtos and the tutorials. Please read them.

I would second that advice. What Kevin was attempting is already done well and correctly in the online documentation. Please don't fill the list archives with unnecessary explanations - especially incorrect ones.

--
Dick St.Peters, [email protected]