Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Justin Friel <capn_shoe@yahoo.com>
To: netfilter lists <netfilter@lists.netfilter.org>
Subject: Re: mangle, filter & FORWARD
Date: Mon, 31 May 2004 14:39:04 -0700 (PDT)	[thread overview]
Message-ID: <20040531213904.58654.qmail@web60002.mail.yahoo.com> (raw)
In-Reply-To: <20040531201412.91688.qmail@web41708.mail.yahoo.com>

Hi Kevin,

Though, as you know, I'm no expert on iptables, I
think I can answer some of your questions. If I am
incorrect, someone please set me right.

--- "Kevin D. White" <web_crawlz@yahoo.com> wrote:
> Does a packet that needs to be forwarded ever hit
> the
> INPUT chain? 

No, it goes directly to the FORWARD chain.  

Taken directly from the Packet Filtering HOWTO
(http://www.netfilter.org/documentation/HOWTO//packet-filtering-HOWTO-6.html):
                         _____
Incoming                 /     \         Outgoing
       -->[Routing ]--->|FORWARD|------->
          [Decision]     \_____/        ^
               |                        |
               v                       ____
              ___                     /    \
             /   \                  |OUTPUT|
            |INPUT|                  \____/
             \___/                      ^
               |                        |
                ----> Local Process ----
   1. When a packet comes in (say, through the
Ethernet card) the kernel first looks at the
destination of the packet: this is called `routing'.
   2. If it's destined for this box, the packet passes
downwards in the diagram, to the INPUT chain. If it
passes this, any processes waiting for that packet
will receive it.
   3. Otherwise, if the kernel does not have
forwarding enabled, or it doesn't know how to forward
the packet, the packet is dropped. If forwarding is
enabled, and the packet is destined for another
network interface (if you have another one), then the
packet goes rightwards on our diagram to the FORWARD
chain. If it is ACCEPTed, it will be sent out.
   4. Finally, a program running on the box can send
network packets. These packets pass through the OUTPUT
chain immediately: if it says ACCEPT, then the packet
continues out to whatever interface it is destined
for.



> What is the relationship between mangle & filter
> tables and the chain FORWARD, are there two FORWARD
> chains; one for mangle and one for filter or do they
> share the same chain?.

Yes, I believe there are two FORWARD chains, this is
from the iptables man page:

filter:
    This is the default table (if no -t option is 
passed).   It contains  the built-in chains INPUT (for
packets coming into the box itself), FORWARD (for
packets being  routed  through the box), and OUTPUT
(for locally-generated packets).
                                                      
                         
nat:
    This  table  is  consulted  when a packet that
creates a new connection is encountered.  It consists
of three  built-ins: PREROUTING  (for  altering
packets as soon as they come in), OUTPUT (for altering
locally-generated packets before  rout-               
ing),  and  POSTROUTING  (for  altering  packets as
they are about to go out).
                                                      
                         
mangle:
    This table is used for specialized packet
alteration.  Until kernel  2.4.17  it  had two
built-in chains: PREROUTING (for altering incoming
packets before routing)  and  OUTPUT  (for altering 
locally-generated  packets before routing).  Since
kernel 2.4.18, three other built-in  chains  are  also
 supported: INPUT (for packets coming into the box
itself), FORWARD (for altering packets being routed 
through  the  box), and  POSTROUTING  (for altering
packets as they are about to go out).


> When is the decision to move the packet out the
> internal interface made, or is this something I must
> specify?
> 

If I am correct the decision is made by the OUTPUT
chain.


Hope this helps,
Justin.


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


  reply	other threads:[~2004-05-31 21:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-31 20:14 mangle, filter & FORWARD Kevin D. White
2004-05-31 21:39 ` Justin Friel [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-06-01 17:28 Kevin D. White
2004-06-01 17:58 Daniel Chemko
2004-06-02  5:17 ` Kevin D. White
2004-06-02  6:34   ` Ludo Stellingwerff
2004-06-02 15:04     ` Dick St.Peters

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040531213904.58654.qmail@web60002.mail.yahoo.com \
    --to=capn_shoe@yahoo.com \
    --cc=netfilter@lists.netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox