在OpenVZ CEntOS容器上的iptables端口转发

我正尝试在运行CentOS 5.5的OpenVZ容器上设置一个简单的端口转发。 当我运行一个命令时,我得到错误。

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 iptables v1.3.5: can't initialize iptables table `nat': Table does not exist (do you need to insmod?) Perhaps iptables or your kernel needs to be upgraded. 

相同的命令在硬件节点或任何其他物理服务器上正常工作。 我知道我可以在硬件节点上为特定容器设置端口转发,但那不是解决scheme。

看起来您的OpenVZ主机节点没有为VM guest虚拟机启用netfilter支持。 如果您是OpenVZ主机的pipe理员,那么请参阅OpenVZ wiki页面上标题为“设置允许每个容器configuration的防火墙”的部分。

 modprobe ip_tables modprobe ip_conntrack modprobe iptable_filter modprobe ipt_state 

尝试任何这些..

我会猜测iptable_filter ..

然后再次运行命令..

 iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 

有用吗?