Skip to contentSkip to conversation

ipchains + mark in output chain ?

LARTC Ludovic Drolez 5 participants 8 messages Jun 12, 2002 – Jun 17, 2002

lore
Share & tools
lore
#0 lore raw

Hi !

I'm marking packets to classify them with ipchains.
For example, to mark packets which will go to the internet (ppp0) I do:

/sbin/ipchains -A input -i eth0 -s 192.168.0.0/16 -d ! 192.168.0.0/16 -b -m 100

Can I do mark them on the output chain (ipchains -A output -i ppp0 -m
100) and still have QoS working properly ?

In other words, what does the kernel:
- packet -> input(mark) -> forward -> output(mark) -> qos/egress
- or packet -> input -> forward -> qos/egress -> output(mark) ?

TIA,

Signature · 7 lines
Ludovic DROLEZ                                       Free&ALter Soft
152, rue de Grigy - Technopole Metz 2000                  57070 METZ
tel : 03 87 75 55 21                            fax : 03 87 75 19 26

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
#1 lore raw
Quoted 11 lines · Ludovic Drolez

Hi !

I'm marking packets to classify them with ipchains.
For example, to mark packets which will go to the internet (ppp0) I do:

/sbin/ipchains -A input -i eth0 -s 192.168.0.0/16 -d ! 192.168.0.0/16 -b -m 100

Can I do mark them on the output chain (ipchains -A output -i ppp0 -m
100) and still have QoS working properly ?

Yes you can.

Quoted 2 lines

In other words, what does the kernel:
- packet -> input(mark) -> forward -> output(mark) -> qos/egress

Yep

Quoted 1 line

- or packet -> input -> forward -> qos/egress -> output(mark) ?

Nop

Stef

Signature · 7 lines
[email protected]
 "Using Linux as bandwidth manager"
     http://www.docum.org/
     #lartc @ irc.openprojects.net
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
#2 lore raw
In reply to Ludovic Drolez
Quoted 9 lines · answering to Ludovic Drolez
Quoted 2 lines

Can I do mark them on the output chain (ipchains -A output -i ppp0 -m
100) and still have QoS working properly ?

Yes you can.

Quoted 2 lines

In other words, what does the kernel:
- packet -> input(mark) -> forward -> output(mark) -> qos/egress

Yep

Nop again. I understand what Stef is trying to say but it could be confused because you are using input(mark) to refer to prerouting.

Really does not exist such a path input -> forward -> output -> qos thru the kernel.

Exists the path prerouting -> forward -> postrouting.

I have seen people in the list trying to use Linux as a router and applying iptables over the INPUT and OUTPUT chains when those are not transversed by packets when the box is a router; just use FORWARD.

If you are trying to say that input(mark) is the chain for marking packets before entering the kernel use instead PREROUTING to keep things clear for all of us.

This diagram, subject to discusion and improvement for more experimented people in the list to be depurated, can help to clarify things:

                                   Network
                           -----------+-----------
                                      |
                              +-------+------+
                              |    mangle    |
                              |  PREROUTING  |
                              +-------+------+
                                      |
                              +-------+------+    Policy rule database
                              |     PRDB     | <- controlled by ip rule
                              +-------+------+
                                      |
                              +-------+------+
                              |      nat     |
                              |  PREROUTING  |
                              +-------+------+
                                      |
               packet is for  +-------+------+ packet is for
               this address   |   ROUTING    | another address
               +--------------+  DECISION ?  +---------------+
               |              +--------------+               |
       +-------+------+                                      |
       |    filter    |                                      |
       |    INPUT     |                                      |
       +-------+------+                                      |
               |                                             |
       +-------+------+                                      |
       |    Local     |                                      |
       |   Process    |                                      |
       +-------+------+                                      |
               |                                             |
       +-------+------+                               +------+------+
       |    mangle    |                               |   filter    |
       |    OUTPUT    |                               |   FORWARD   |
       +-------+------+                               +------+------+
               |                                             |
       +-------+------+                                      |
       |     nat      |                                      |
       |    OUTPUT    |                                      |
       +-------+------+                                      |
               |                                             |
       +-------+------+                                      |
       |    filter    |                                      |
       |    OUTPUT    |                                      |
       +-------+------+                                      |
               |              +--------------+               |
               +--------------+   ROUTING    +---------------+
                              |  DECISION ?  | <- controlled by ip route
                              +-------+------+
                                      |
                              +-------+------+
                              |     nat      |
                              | POSTROUTING  |
                              +-------+------+
                                      |
                              +-------+------+
                              |   TRAFFIC    |
                              |    QUEUE     | <- controlled by tc
                              +-------+------+
                                      |
                           -----------+-----------
                                   Network

After all of us agree the diagram could be published at Stef site (with his permission, of course) to be have as a reference to people using the list.

Also, Ludovic, I really recommend you to migrate from ipchains to iptables. Last is a lot better code, well designed and clearer to understand than ipchains. Really try to do it.

Best regards,

Leonardo Balliache
[email protected]

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#3 lore raw
In reply to Ludovic Drolez

Hello,

Quoted 26 lines · Leonardo Balliache

This diagram, subject to discusion and improvement for more experimented people in the list to be depurated, can help to clarify things:

                                   Network
                           -----------+-----------
                                      |
                              +-------+------+
                              |    mangle    |
                              |  PREROUTING  |
                              +-------+------+
                                      |
                              +-------+------+    Policy rule database
                              |     PRDB     | <- controlled by ip rule
                              +-------+------+
                                      |
                              +-------+------+
                              |      nat     |
                              |  PREROUTING  |
                              +-------+------+
                                      |
               packet is for  +-------+------+ packet is for
               this address   |   ROUTING    | another address
               +--------------+  DECISION ?  +---------------+
               |              +--------------+               |
       +-------+------+                                      |
Quoted 8 lines
       |    filter    |                                      |
       |    INPUT     |                                      |
       +-------+------+                                      |
               |                                             |
       +-------+------+                                      |
       |    Local     |                                      |
       |   Process    |                                      |
       +-------+------+                                      |

ROUTING

Quoted 34 lines
               |                                             |
       +-------+------+                               +------+------+
       |    mangle    |                               |   filter    |
       |    OUTPUT    |                               |   FORWARD   |
       +-------+------+                               +------+------+
               |                                             |
       +-------+------+                                      |
       |     nat      |                                      |
       |    OUTPUT    |                                      |
       +-------+------+                                      |
               |                                             |
       +-------+------+                                      |
       |    filter    |                                      |
       |    OUTPUT    |                                      |
       +-------+------+                                      |
               |              +--------------+               |
               +--------------+   ROUTING    +---------------+
                              |  DECISION ?  | <- controlled by ip route
                              +-------+------+
                                      |
                              +-------+------+
                              |     nat      |
                              | POSTROUTING  |
                              +-------+------+
                                      |
                              +-------+------+
                              |   TRAFFIC    |
                              |    QUEUE     | <- controlled by tc
                              +-------+------+
                                      |
                           -----------+-----------
                                   Network
Quoted 2 lines

After all of us agree the diagram could be published at Stef site (with his permission, of course) to be have as a reference to people using the list.

Where is the routing decision of the local process, before
OUTPUT? Or only I see it :) Also, there is a big difference between input and output routing decision, may be this diagram can show it :)

Quoted 4 lines

Best regards,

Leonardo Balliache
[email protected]

Regards

--
Julian Anastasov <[email protected]>

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#4 lore raw
In reply to Ludovic Drolez

but the diagram is for iptables

ipchains, do for ex a pachet that traverse the router:
net -> input chain -> routing -> forward chain -> output chain

if i remember well

and for the iptables see a great picture :-) at :
http://people.unix-fu.org/andreasson/iptables-tutorial/images/tables_traverse.jpg

C

Quoted 95 lines · Julian Anastasov

Hello,

Quoted 26 lines · Leonardo Balliache

This diagram, subject to discusion and improvement for more experimented people in the list to be depurated, can help to clarify things:

                                  Network
                          -----------+-----------
                                     |
                             +-------+------+
                             |    mangle    |
                             |  PREROUTING  |
                             +-------+------+
                                     |
                             +-------+------+    Policy rule database
                             |     PRDB     | <- controlled by ip rule
                             +-------+------+
                                     |
                             +-------+------+
                             |      nat     |
                             |  PREROUTING  |
                             +-------+------+
                                     |
              packet is for  +-------+------+ packet is for
              this address   |   ROUTING    | another address
              +--------------+  DECISION ?  +---------------+
              |              +--------------+               |
      +-------+------+                                      |
Quoted 9 lines
      |    filter    |                                      |
      |    INPUT     |                                      |
      +-------+------+                                      |
              |                                             |
      +-------+------+                                      |
      |    Local     |                                      |
      |   Process    |                                      |
      +-------+------+                                      |

ROUTING

Quoted 34 lines
              |                                             |
      +-------+------+                               +------+------+
      |    mangle    |                               |   filter    |
      |    OUTPUT    |                               |   FORWARD   |
      +-------+------+                               +------+------+
              |                                             |
      +-------+------+                                      |
      |     nat      |                                      |
      |    OUTPUT    |                                      |
      +-------+------+                                      |
              |                                             |
      +-------+------+                                      |
      |    filter    |                                      |
      |    OUTPUT    |                                      |
      +-------+------+                                      |
              |              +--------------+               |
              +--------------+   ROUTING    +---------------+
                             |  DECISION ?  | <- controlled by ip route
                             +-------+------+
                                     |
                             +-------+------+
                             |     nat      |
                             | POSTROUTING  |
                             +-------+------+
                                     |
                             +-------+------+
                             |   TRAFFIC    |
                             |    QUEUE     | <- controlled by tc
                             +-------+------+
                                     |
                          -----------+-----------
                                  Network
Quoted 3 lines

After all of us agree the diagram could be published at Stef site (with his permission, of course) to be have as a reference to people using the list.

Where is the routing decision of the local process, before
OUTPUT? Or only I see it :) Also, there is a big difference between input and output routing decision, may be this diagram can show it :)

Quoted 5 lines

Best regards,

Leonardo Balliache
[email protected]

Quoted 9 lines

Regards

--
Julian Anastasov <[email protected]>

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#5 lore raw
In reply to Ludovic Drolez

Hello,

Quoted 1 line · Ciprian Niculescu

but the diagram is for iptables

Yes, I know.

Quoted 2 lines

and for the iptables see a great picture :-) at :
http://people.unix-fu.org/andreasson/iptables-tutorial/images/tables_traverse.jpg

Another wrong picture for iptables

Regards

--
Julian Anastasov <[email protected]>

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#6 lore raw
In reply to Ludovic Drolez
Quoted 7 lines · Julian Anastasov

Hello,

Quoted 1 line · Ciprian Niculescu

but the diagram is for iptables

Yes, I know.

aa ok, so why the subject is ipchains? :-)

Quoted 5 lines
Quoted 4 lines

and for the iptables see a great picture :-) at :
http://people.unix-fu.org/andreasson/iptables-tutorial/images/tables_traverse.jpg

Another wrong picture for iptables

why???

C

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#7 lore raw
In reply to Ludovic Drolez

Hello,

Quoted 1 line · Ciprian Niculescu

aa ok, so why the subject is ipchains? :-)

I'm just replying to the proposed iptables diagram.

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

http://people.unix-fu.org/andreasson/iptables-tutorial/images/tables_traverse.jpg

Another wrong picture for iptables

why???

Read my posting again. The routing decision is before
OUTPUT not after OUTPUT. It should be looking something like:

local process -> output routing -> OUTPUT+output_rerouting(s) -> ...

Another problem: to what routing decision refers the diagram after forward?

The forwarding should be:

prerouting -> input routing -> forward -> post_routing

Another bug, this time in the netfilter sources (iptable_mangle.c):

output_rerouting called from INPUT

Quoted 1 line

C

Regards

--
Julian Anastasov <[email protected]>

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/