我已经使用
this link在ubuntu服务器12.04中安装了LXC.它已成功安装,我可以使用ubutu / ubuntu作为用户名和密码登录.然后我尝试为LXC容器设置网络.
我在/ 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
容器等/网络/接口
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
这就是我的配置
------------- ----------- ----------- | 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 is 1
我添加了Nat规则
ip_tables -t nat -A POSTROUTING -s 125.67.43.102 -o eth0 -j MASQUERADE
注意:我上面使用的IP不是原创的
也许这个链接会回答你的问题:
https://wiki.debian.org/LXC/SimpleBridge
原文链接:https://www.f2er.com/ubuntu/348065.htmlhttps://wiki.debian.org/LXC/SimpleBridge
看起来你应该在主机上配置br0而不是eth0(例子中的第一个代码块).
不过我只是在猜测!
您的广播地址与网络不匹配,我将在上面的示例中使用125.67.43.255.