Skip to contentSkip to conversation

Interface match in POSTROUTING

DISCUSSION Oleg A. Arkhangelsky 2 participants 2 messages Oct 9, 2011 netfilter

lore
Share & tools
lore
#0 lore raw

Hello,

I have a question regarding this piece of code in iptables.c:

                if (strcmp(chain, "POSTROUTING") == 0
                    || strcmp(chain, "OUTPUT") == 0) {
                        /* -i not valid with outgoing packets */
                        if (cs.options & OPT_VIANAMEIN)
                                xtables_error(PARAMETER_PROBLEM,
                                           "Can't use -%c with %s\n",
                                           opt2char(OPT_VIANAMEIN),
                                           chain);
                }

I agree that "-i" is not valid for locally generated packets (that is what OUTPUT chain for). But for forwarded packets going through POSTROUTING this is not true. As far as I understand we can match for both input and output interface here (as in FORWARD).

So why we need this restriction?

Signature · 1 line
wbr, Oleg.
#1 lore raw
Quoted 14 lines · Oleg A. Arkhangelsky

Hello,

I have a question regarding this piece of code in iptables.c:

               if (strcmp(chain, "POSTROUTING") == 0
                   || strcmp(chain, "OUTPUT") == 0) {
                       /* -i not valid with outgoing packets */
                       if (cs.options & OPT_VIANAMEIN)
                               xtables_error(PARAMETER_PROBLEM,
                                          "Can't use -%c with %s\n",
                                          opt2char(OPT_VIANAMEIN),
                                          chain);
               }
Quoted 5 lines

I agree that "-i" is not valid for locally generated packets (that is what OUTPUT chain for). But for forwarded packets going through POSTROUTING this is not true. As far as I understand we can match for both input and output interface here (as in FORWARD).

Locally generated packets also appear in POSTROUTING.