通过特定的networking接口从cgroup路由stream量

是否有可能将cgroup限制到特定的networking接口? 所有来自cgroup的数据包只能通过VPN连接进行路由,而其他数据包使用默认路由。

使用unix用户可以使用iptables“-m owner –set-mark”,然后使用“ip rule”进行路由。

可以匹配一个cgroup吗? iptables似乎不支持这个。

对-m cgroup的iptables支持尚未发布,但您可以轻松地自行构build扩展并将其安装在您的系统上:

git clone git://git.netfilter.org/iptables.git cd iptables ./autogen.sh ./configure make -k sudo cp extensions/libxt_cgroup.so /lib/xtables/ sudo chmod -x /lib/xtables/libxt_cgroup.so 

使用-m cgroup 。 例:

 iptables -A OUTPUT -m cgroup ! --cgroup 1 -j DROP 

来自: http : //lwn.net/Articles/569678/