Linux

將所有從特定介面發出的數據包發送到 nfqueue

  • March 15, 2012

在測試環境中,程序將數據包從特定介面發送出去。我希望能夠將所有從所述介面發出的數據包發送到 nfqueue。我可以通過執行以下操作對介面上的傳入數據包執行此操作:

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

但是,嘗試對任何出站表執行相同操作會導致錯誤,即 -i 選項無效。這有可能實現嗎?如果可以,如何實現?

-i用於傳入的數據包。

用於-o傳出數據包。

您可以在手冊頁中找到解釋:

  [!] -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.

或在輸出中iptables --help

[!] --out-interface -o output name[+]
               network interface name ([+] for wildcard)

引用自:https://serverfault.com/questions/370154