Karmic iptables在OpenVZ容器上缺less内核模块

在将我的Ubuntu服务器的p2v迁移到OpenVZ容器之后,我认为我会试着重新安装一个基于干净的OpenVZ模板的Ubuntu 9.10(来自OpenVZ维基)

当我尝试在VM机器上加载我的iptables规则时,我收到了错误,我认为这些错误与内核模块没有从/vz/XXX.conf模板模型中加载到VM上有关。

我已经testing了几个post,我发现,但我是堆栈的错误:

WARNING: Deprecated config file /etc/modprobe.conf, all config files belong into /etc/modprobe.d/. FATAL: Could not load /lib/modules/2.6.24-10-pve/modules.dep: No such file or directory iptables-restore v1.4.4: iptables-restore: unable to initialize table 'raw' Error occurred at line: 2 Try `iptables-restore -h' or 'iptables-restore --help' for more information. 

我读了关于模板不加载所有的iptables模块,所以我添加模块到VZ虚拟机的XXX.conf是这样的:

 IPTABLES="ip_tables iptable_filter iptable_mangle ipt_limit ipt_multiport ipt_tos ipt_TOS ipt_REJECT ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_LOG ipt_length ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_conntrack ipt_state ipt_helper iptable_nat ip_nat_ftp ip_nat_irc" 

由于错误仍然存​​在,我读到应该在虚拟机上再次build立依赖关系:

 depmod -a but this returned an error: WARNING: Couldn't open directory /lib/modules/2.6.24-10-pve: No such file or directory FATAL: Could not open /lib/modules/2.6.24-10-pve/modules.dep.temp for writing: No such file or directory 

所以我再读一遍关于创build目录空白和重做“depmod -a”它。

我现在没有得到依赖错误,但得到这个,我不知道如何进行:

 WARNING: Deprecated config file /etc/modprobe.conf, all config files belong into /etc/modprobe.d/. FATAL: Module ip_tables not found. iptables-restore v1.4.4: iptables-restore: unable to initialize table 'raw' Error occurred at line: 2 Try `iptables-restore -h' or 'iptables-restore --help' for more information. 

我知道iptables规则必须在VM机器上有所不同,也许我们试图应用的一些规则(来自我们的物理服务器)是不兼容的,但这些只是源IP和目标端口检查,我​​希望能够有空。 我听说在CentOS模板上没有这个问题,所以我理解的是使用VMconfiguration。

任何帮助将不胜感激。

我曾经一次问过同样的问题 :)原来,在VE里面你需要至less2.6.32-ovz的RAW。

不是一个直接的答案,但对于我的openvz机器,我把我的iptables规则放在主机上。 然后他们在一个地方,而且每个人都必须去主机。 你可能会发现这更简单,更清洁(但也许不)。

根据这篇文章 ,主机节点上需要一些设置。 (下面的文本大部分来自文章,但不是被引用的,以使其更具可读性。)

首先,主机节点应该转发所有stream量。 以下命令使默认的FORWARD操作成为ACCEPT,然后刷新FORWARD链上的所有规则。

 iptables -P FORWARD ACCEPT iptables -F FORWARD 

如果要在容器内使用防火墙,请在启动容器之前加载这些模块:

 modprobe xt_tcpudp modprobe ip_conntrack 

如果你不这样做,你会得到这样的错误:“iptables:没有链/目标/匹配的名称”

如果你想使用有状态的防火墙规则(你应该!),你还需要确保'ipt_state'在你的vz.conf文件的'IPTABLES'选项中:

 IPTABLES="ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state" 

还要确保在主机上加载了“xt_state”模块:

 modprobe xt_state