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.

相关文章

目录前言一、创建Hadoop用户二、更新apt和安装Vim编辑器三、...
原文连接:https://www.cnblogs.com/yasmi/p/5192694.html ...
电脑重启后,打开VirtualBox,发现一直用的虚拟机莫名的消失...
参见:https://blog.csdn.net/weixin_38883338/article/deta...
Ubuntu 18.04 LTS 已切换到 Netplan 来配置网络接口。Netpla...
介绍每个 Web 服务都可以通过特定的 URL 在 Internet 上访问...