Skip to contentSkip to conversation

mangle table traversal

DISCUSSION Shinju 4 participants 5 messages Jun 20, 2002

lore
Share & tools
lore

Shinju

author
#0 lore raw

Hey folks.

Do packets always traverse the chain in the 'mangle' table before they traverse the corresponding chain in other tables? In other words, is this flow correct?...

...manglePREROUTING --> natPREROUTING...
...mangleINPUT --> filterINPUT...
...mangleOUTPUT --> natOUTPUT --> filterOUTPUT...
...mangleFORWARD --> filterFORWARD...
...manglePOSTROUTING --> natPOSTROUTING...

thanks

#1 lore raw
Quoted 11 lines · Shinju

Hey folks.

Do packets always traverse the chain in the 'mangle' table before they traverse the corresponding chain in other tables? In other words, is this flow correct?...

...manglePREROUTING --> natPREROUTING...
...mangleINPUT --> filterINPUT...
...mangleOUTPUT --> natOUTPUT --> filterOUTPUT...
...mangleFORWARD --> filterFORWARD...
...manglePOSTROUTING --> natPOSTROUTING...

You can eaily check this for yourself by putting a LOG target as the first rule into every chain. eg:

iptables -t mangle -I PREROUTING -j LOG --log-prefix=PreMangle iptables -t mangle -I INPUT -j LOG --log-prefix=InMangle iptables -t mangle -I FORWARD -j LOG --log-prefix=ForMangle iptables -t mangle -I POSTROUTING -j LOG --log-prefix=PostMangle iptables -t mangle -I OUTPUT -j LOG --log-prefix-OutMangle iptables -t filter -I PREROUTING -j LOG --log-prefix=PreFilt iptables -t filter -I INPUT -j LOG --log-prefix=InFilt iptables -t filter -I FORWARD -j LOG --log-prefix=ForFilt iptables -t filter -I POSTROUTING -j LOG --log-prefix=PostFilt iptables -t filter -I OUTPUT -j LOG --log-prefix-OutFilt iptables -t nat -I PREROUTING -j LOG --log-prefix=PreNat iptables -t nat -I POSTROUTING -j LOG --log-prefix=PostNat iptables -t nat -I OUTPUT -j LOG --log-prefix-OutNat

Then just send somepackets through the machine and look at the log file to see what order they went through the chains/tables.

Antony.

#2 lore raw

Interestingly, iptables 1.2.6a won't let me attach a LOG target to any of the output chains. I get this:

bash-2.05a# iptables -t mangle -I OUTPUT -j LOG --log-prefix-OutMangle iptables v1.2.6a: Unknown arg `--log-prefix-OutMangle'

Is that expected behavior, and if so, why?

Quoted 38 lines · Antony Stone
Quoted 11 lines · Shinju

Hey folks.

Do packets always traverse the chain in the 'mangle' table before they traverse the corresponding chain in other tables? In other words, is this flow correct?...

...manglePREROUTING --> natPREROUTING...
...mangleINPUT --> filterINPUT...
...mangleOUTPUT --> natOUTPUT --> filterOUTPUT...
...mangleFORWARD --> filterFORWARD...
...manglePOSTROUTING --> natPOSTROUTING...

You can eaily check this for yourself by putting a LOG target as the first rule into every chain. eg:

iptables -t mangle -I PREROUTING -j LOG --log-prefix=PreMangle iptables -t mangle -I INPUT -j LOG --log-prefix=InMangle iptables -t mangle -I FORWARD -j LOG --log-prefix=ForMangle iptables -t mangle -I POSTROUTING -j LOG --log-prefix=PostMangle iptables -t mangle -I OUTPUT -j LOG --log-prefix-OutMangle iptables -t filter -I PREROUTING -j LOG --log-prefix=PreFilt iptables -t filter -I INPUT -j LOG --log-prefix=InFilt iptables -t filter -I FORWARD -j LOG --log-prefix=ForFilt iptables -t filter -I POSTROUTING -j LOG --log-prefix=PostFilt iptables -t filter -I OUTPUT -j LOG --log-prefix-OutFilt iptables -t nat -I PREROUTING -j LOG --log-prefix=PreNat iptables -t nat -I POSTROUTING -j LOG --log-prefix=PostNat iptables -t nat -I OUTPUT -j LOG --log-prefix-OutNat

Then just send somepackets through the machine and look at the log file to see what order they went through the chains/tables.

Antony.

#3 lore raw
Quoted 5 lines · Ben

Interestingly, iptables 1.2.6a won't let me attach a LOG target to any of the output chains. I get this:

bash-2.05a# iptables -t mangle -I OUTPUT -j LOG --log-prefix-OutMangle iptables v1.2.6a: Unknown arg `--log-prefix-OutMangle'

Sorry - my typo....

try using

iptables -t mangle -I OUTPUT -j LOG --log-prefix=OutMangle

instead :-)

Antony.

#4 lore raw
In reply to Ben

Syntax:

Quoted 1 line

bash-2.05a# iptables -t mangle -I OUTPUT -j LOG --log-prefix-OutMangle

should be --log-prefix=OutMangle
----- Original Message -----
From: "Ben" <[email protected]>
To: "Antony Stone" <[email protected]>
Cc: <[email protected]>
Sent: Thursday, June 20, 2002 4:14 PM
Subject: Re: mangle table traversal

Quoted 16 lines

Interestingly, iptables 1.2.6a won't let me attach a LOG target to any of the output chains. I get this:

bash-2.05a# iptables -t mangle -I OUTPUT -j LOG --log-prefix-OutMangle iptables v1.2.6a: Unknown arg `--log-prefix-OutMangle'

Is that expected behavior, and if so, why?

Quoted 6 lines · Antony Stone
Quoted 4 lines · Shinju

Hey folks.

Do packets always traverse the chain in the 'mangle' table before they traverse the corresponding chain in other tables? In other words, is

this

Quoted 9 lines
Quoted 9 lines
Quoted 7 lines

flow correct?...

...manglePREROUTING --> natPREROUTING...
...mangleINPUT --> filterINPUT...
...mangleOUTPUT --> natOUTPUT --> filterOUTPUT...
...mangleFORWARD --> filterFORWARD...
...manglePOSTROUTING --> natPOSTROUTING...

You can eaily check this for yourself by putting a LOG target as the

first

Quoted 16 lines
Quoted 16 lines

rule into every chain. eg:

iptables -t mangle -I PREROUTING -j LOG --log-prefix=PreMangle iptables -t mangle -I INPUT -j LOG --log-prefix=InMangle iptables -t mangle -I FORWARD -j LOG --log-prefix=ForMangle iptables -t mangle -I POSTROUTING -j LOG --log-prefix=PostMangle iptables -t mangle -I OUTPUT -j LOG --log-prefix-OutMangle iptables -t filter -I PREROUTING -j LOG --log-prefix=PreFilt iptables -t filter -I INPUT -j LOG --log-prefix=InFilt iptables -t filter -I FORWARD -j LOG --log-prefix=ForFilt iptables -t filter -I POSTROUTING -j LOG --log-prefix=PostFilt iptables -t filter -I OUTPUT -j LOG --log-prefix-OutFilt iptables -t nat -I PREROUTING -j LOG --log-prefix=PreNat iptables -t nat -I POSTROUTING -j LOG --log-prefix=PostNat iptables -t nat -I OUTPUT -j LOG --log-prefix-OutNat

Quoted 1 line
Quoted 1 line

Then just send somepackets through the machine and look at the log file

to

Quoted 9 lines
Quoted 6 lines

see what order they went through the chains/tables.

Antony.