2016-06-22 28 views
1

这是我第一次设置LXD运行多个容器。我已经完成了所有配置步骤,但是我的容器没有从组织内运行的DHCP服务器获取IP地址。请帮助我。Linux LXD容器没有从DHCP获取IP Ubuntu 16.04 TLS

我正在使用Bridge接口配置文件。下面是我做了更改:

[email protected]:~# vi /etc/network/interfaces 

auto br0 
iface br0 inet dhcp 
    bridge-ports ens32 
    bridge-ifaces ens32 
iface ens32 inet dhcp 


[email protected]:~# lxc list 
| NAME  | STATE |  IPV4  | IPV6 | TYPE | SNAPSHOTS | 
| Continer1 | RUNNING |     |  | PERSISTENT | 0   | 

IP and interface details what i setup on my ubuntu machine

Dhcp message when doing ifdown eth0 && ifup eth0 inside container

+1

检查你的新容器的IP地址,你应该写你的问题,激励方式无偿支付的人 – zanderwar

+0

现在好像没事了,请帮助我 – Amar

回答

2

这是一个老问题,但我决定回答这个问题,因为我被困在同一个主题,解决ISN” t完全明显。

如果您希望容器从外部设备(例如互联网路由器,公司dhcp服务器)获取其IP配置,则需要在创建时告诉它。这是通过一个配置参数对user.network_mode=dhcp 由于这个配置是在“用户”空间,它没有规范,但工作在Ubuntu 16.04。有关详细信息,请参阅:https://github.com/lxc/lxd/blob/master/doc/configuration.md

步骤1:/etc/network/interfaces

auto br0 
iface br0 inet dhcp 
    bridge_ports ens32 
    bridge_stp off 
    bridge_fd 0 

步骤2在主机上创建桥:创建你自己的LXD个人资料被称为mydhcp

lxd profile create mydhcp 

或重新配置默认LXD配置打电话

sudo dpkg-reconfigure -p medium lxd 

(You ne编辑在第一次提示选择并添加第二个提示,然后输入你的桥的名字)

如果使用自己的个人资料,编辑

lxc profile edit mydhcp 

粘贴以下

name: mydhcp 
config: 
    user.network_mode: dhcp 
description: Profile for creating dhcp containers 
devices: 
    eth0: 
    name: eth0 
    nictype: bridged 
    parent: br0 
    type: nic 

(注意空格 - 这是YAML文件,空格很重要!)

第3步:使用你的mydhcp配置文件创建一个新容器

lxc launch ubuntu:16.04 mydhcpcontainer -p mydhcp -c user.network_mode=dhcp 

如果在上一步中更改了默认LXD配置,只需输入

lxc launch ubuntu:16.04 mydhcpcontainer -c user.network_mode=dhcp 

lxc exec mydhcpcontainer -- ifconfig