我已经使用这个链接在Ubuntu的服务器12.04安装LXC。 它已成功安装,我可以使用ubutu / ubuntu作为用户名和密码login。 然后我试图为LXC容器设置networking。
我在/ etc / network / interface中更改为
auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 125.67.43.100 netmask 255.255.255.0 broadcast 178.33.40.255 gateway 125.67.43.1
/ var / lib / lxc / mycontainer / config的内容是:
lxc.utsname = mycontainer lxc.mount = /var/lib/lxc/test/fstab lxc.rootfs = /var/lib/lxc/test/rootfs lxc.network.type = veth lxc.network.flags = up lxc.network.link = br0 lxc.network.name = eth0 lxc.network.veth.pair = vethmycontainer lxc.network.ipv4 = 125.67.43.102 lxc.network.hwaddr= 02:00:00:86:5b:11 lxc.devttydir = lxc lxc.tty = 4 lxc.pts = 1024 lxc.arch = amd64 lxc.cap.drop = sys_module mac_admin mac_override lxc.pivotdir = lxc_putold
容器等/networking/接口
auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 125.67.43.102 netmask 255.255.255.0 broadcast 178.33.40.255 gateway 125.67.43.1
这是我的configuration
------------- ----------- ----------- | LXC | -----> | Host OS | ------> | Gateway | | Container | | Ubuntu | | | ------------- ----------- ----------- eth0 125.67.43.102 br0 <-> eth0 NAT GW: gw 125.67.43.1 br0 125.67.43.100 125.67.43.1 gw 125.67.43.1 Ping 125.67.43.100 ping 125.67.43.1 ok OK Ping 125.67.43.1 ping 125.67.43.102 FAIL OK
LXC容器不知道外部主机,有什么想法,我在这里犯了什么错误?
附加信息
user @ host $ cat / proc / sys / net / ipv4 / ip_forward是1
我已经添加了Nat规则
ip_tables -t nat -A POSTROUTING -s 125.67.43.102 -o eth0 -j MASQUERADE
注:我上面使用的IP不是原创的
也许这个链接将回答你的问题: https : //wiki.debian.org/LXC/SimpleBridge
好像你应该在主机上configurationbr0而不是eth0(在你的例子中是第一个代码块)。
虽然我只是猜测!
你的广播地址与networking不匹配,我将在上面的例子中使用125.67.43.255。
你的br0应该是你的容器的网关。 请检查lxc.network.ipv4语法。 也许你应该把子网掩码。