微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ubuntu – 使用公共IP的LXC网络

我已经使用 this linkubuntu服务器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

看起来你应该在主机上配置br0而不是eth0(例子中的第一个代码块).

不过我只是在猜测!

您的广播地址与网络不匹配,我将在上面的示例中使用125.67.43.255.

原文地址:https://www.jb51.cc/ubuntu/348065.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐