iptables -p all –dport

iptables似乎不能识别--dport -p all

 iptables -A INPUT -p all --dport www -j ACCEPT 

收益率:

 iptables v1.4.4: unknown option `--dport' Try `iptables -h' or 'iptables --help' for more information. --destination-port doesn't work either: iptables v1.4.4: unknown option `--destination-port' 

-p tcp-p udp添加两个单独的规则可以正常工作,那为什么不为-p all

万一它很重要,这是在Ubuntu 10.04 LTS服务器与iptables包版本1.4.4-2ubuntu2

–dport不是一般iptables规则的标志。 这是扩展包匹配模块的标志之一。 当您使用-p protocol-m时,这些被加载。 除非用特定协议指定-m <protocol>-p <protocol> ,否则不能使用--dport

您将在iptables(8)手册页中看到:

  tcp These extensions can be used if `--protocol tcp' is specified. It provides the following options: ... [!] --destination-port,--dport port[:port] Destination port or port range specification. The flag --dport is a convenient alias for this option. ... 

不是所有的协议都有一个–dport标志,因为并不是所有的协议都支持端口的概念

“all”不仅包含TCP和UDP, 它也涵盖了像ICMP这样没有端口号概念的协议,因此不能使用–dport参数。