谁能告诉我如何为每个LXC容器设置一个networking接口,以便每个容器可以有自己的专用IP地址?
以下是我的主机节点上的/etc/network/interfaces文件的外观:
# Generated by SolusVM auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 160.201.10.167 gateway 160.201.8.1 netmask 255.255.252.0 dns-nameservers 8.8.8.8 8.8.4.4 auto eth0:0 iface eth0:0 inet static address 160.201.8.32 gateway 160.201.8.1 netmask 255.255.252.0 dns-nameservers 8.8.8.8 8.8.4.4 auto eth0:1 iface eth0:1 inet static address 160.201.8.36 gateway 160.201.8.1 netmask 255.255.252.0 dns-nameservers 8.8.8.8 8.8.4.4 auto eth0:2 iface eth0:2 inet static address 160.201.8.37 gateway 160.201.8.1 netmask 255.255.252.0 dns-nameservers 8.8.8.8 8.8.4.4
这是我的LXC容器configuration文件的样子:
lxc.include = /usr/share/lxc/config/ubuntu.common.conf lxc.rootfs = /var/lib/lxc/francis/rootfs lxc.mount = /var/lib/lxc/francis/fstab lxc.utsname = francis lxc.arch = amd64 lxc.network.type = veth lxc.network.flags = up lxc.network.link = eth0 lxc.network.hwaddr = 00:16:3e:de:53:6f lxc.network.ipv4 = 160.201.8.32 lxc.cgroup.memory.limit_in_bytes = 256M lxc.cgroup.memory.memsw.limit_in_bytes = 256M
任何人都可以告诉我如何给容器“弗朗西斯”自己的公共IP地址,如160.201.8.32例如?
我的主机节点正在运行Ubuntu 14.04服务器。
这取决于你真正想要做什么。
如果你只是希望使你的容器完全自主化,或者只是简单地使它在特定的端口上达到特定的协议。
对于第二种情况,您只需在eth0上启用路由,并在LXC桥上的容器专用IP上为NAT / unNAT特定端口和协议build立NAT规则。
对于第一种情况,您将需要添加另一个网桥,在eth0和新的网桥接口上启用proxy_arp ,并直接将公网IP地址分配给容器veth接口,而不在eth0上使用任何IP别名。 然后设置iptables规则,以避免暴露什么是不必要的networking。