Assigning a LAN IP to a container issues


I starting working on LXD on ubuntu 18 and I am testing the possibility to assign a local IP on each containers to get LAN access.

I tried a method I saw on a poste her with macvlan.

my container is receiving an IP from the LAN dhcp but i am not able to ping anything from the container. From the host I am not able to ping it either, but this I don’t really care.

Weird thing : when I start tcpdump on the container i am able to ping it from another computer on the LAN.

I assigned the container to a new profile copied from default with these parameters :
root@lxd:/home/dom# lxc profile show test
config: {}
description: Default LXD profile
name: eth0
nictype: macvlan
parent: enp0s3
type: nic
path: /
pool: pool1
type: disk
name: test

  • /1.0/containers/inet1

this is my configuration on the host in /etc/network/interfaces:

auto ensp0s3
iface ensp0s3 dhcp

the ip route in the container :slight_smile:

default via dev eth0 proto dhcp src metric 100 dev eth0 proto kernel scope link src dev eth0 proto dhcp scope link src metric 100

can someone put me in the right direction?

thank you,

When you use macvlan, you have this feature where the host becomes inaccessible from the containers. That is, the containers do get their IPs from the LAN and are exposed to the LAN, but there is no network communication between them and the host.
This feature can be beneficial in some cases because it really shields the host from the containers.

Note that there is a way to setup macvlan and still be able to get the host to communication with the containers. That requires through some advanced networking, and I have not seen such instructions.

Having said that, you can use the alternative to macvlan, which is bridge networking to get the same result, and still be able to get the host to communicate with the containers. The somewhat downside is that you need to perform some additional network configuration on the host for this to work.
See the following tutorial on this,


I had it working creating a new bridge on the host called br0, which is bridged to my physical interface.

I assigned that bridge using lxd init and configure the profile to use it.

thank you