Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In a testing environment, a process sends packets out a specific interface. I want be able to send all the packets going out said interface to an nfqueue. I can do this for incoming packets on the interface by doing something like:

iptables -t mangle -A PREROUTING -i eth0 -j NFQUEUE --queue-num 10

However, attempting to do the same thing on any of the outbound tables gives an error that the -i option is invalid. Is this possible to achieve and if so, how so?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

-i is for incoming packets.

Use -o for outgoing packets.

You can find an explanation in the manpage:

   [!] -i, --in-interface name
          Name of an interface via which a packet was received  (only  for
          packets  entering  the  INPUT,  FORWARD  and PREROUTING chains).
          When the "!" argument is used before  the  interface  name,  the
          sense  is  inverted.   If the interface name ends in a "+", then
          any interface which begins with this name will match.   If  this
          option is omitted, any interface name will match.

   [!] -o, --out-interface name
          Name of an interface via which a packet is going to be sent (for
          packets entering the FORWARD, OUTPUT  and  POSTROUTING  chains).
          When  the  "!"  argument  is used before the interface name, the
          sense is inverted.  If the interface name ends in  a  "+",  then
          any  interface  which begins with this name will match.  If this
          option is omitted, any interface name will match.

or in the output of iptables --help:

[!] --out-interface -o output name[+]
                network interface name ([+] for wildcard)
share|improve this answer
    
Was under the impression that -i was for 'interface' as I'm not even seeing -o in this 'iptables help'. Will try this shortly (though I almost hope it wasn't that simple..). Been trying to get this working for awhile, thank you. –  Rauffle Mar 15 '12 at 18:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.