lxd and external access

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.

  1. Install bridge-utils
apt install bridge-utils
  1. Modify /etc/network/interfaces and add
auto br0
iface br0 inet dhcp
  bridge_ports eno1

iface eno1 inet manual
  1. Restart networking on host
service networking restart
  1. Update default profile in lxc
lxc profile edit default

devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: br0
    type: nic
  1. Restart any existing containers
  2. 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         |
+-------------------+---------+------------------+------+------------+-----------+

social