The version of lxd on Ubuntu 16.04 LTS is a little anemic with regards to explaining how to set up networking. I would assume that in many cases it is desirable for the container to be able to receive network requests. By default lxd configures a NAT bridge which means the container can go out, but without some work can't receive messages in.
- Install bridge-utils
apt install bridge-utils
- Modify /etc/network/interfaces and add
auto br0 iface br0 inet dhcp bridge_ports eno1 iface eno1 inet manual
- Restart networking on host
service networking restart
- Update default profile in lxc
lxc profile edit default devices: eth0: name: eth0 nictype: bridged parent: br0 type: nic
- Restart any existing containers
- Assuming you have DHCP configured on the interface containing the bridge, your containers will now get DHCP addresses.
lxc list +-------------------+---------+------------------+------+------------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +-------------------+---------+------------------+------+------------+-----------+ | ultimate-cardinal | RUNNING | 10.0.0.85 (eth0) | | PERSISTENT | 0 | +-------------------+---------+------------------+------+------------+-----------+