Connecting LXD Containers to LAN in Centos 8

Hi Everyone,

Am newbie to LXD containers, I want to connect my containers to my lan and want to use my router settings (gateway, dns, dhcp).
My Setup is LXD in Centos (in VirtualBox).

Thanks in Advance

I’d start by seeing if macvlan would just work for you as that’d be easiest.

You can try something like:

  • lxc init images:ubuntu/20.04 test
  • lxc config device add test eth0 nic nictype=macvlan name=eth0 parent=enp5s0
  • lxc start test

In this case it expects the network interface of your host (CentOS VM) to be enp5s0, if it’s called something else, just change it in that second command.

If this works, after a few seconds you should be able to do lxc list and it should show you an address on the same network that the host (CentOS VM) is connected to.

Note that this may not work for at least a couple of reasons:

  • VirtualBox may interfere with it (restricting the VM guest to a single MAC address)
  • The network card driver used for the VirtualBox NIC inside of your CentOS VM may not properly support macvlan

Hi Stéphane Graber

Thanks fo reply
I’ve done as you said, but no luck i dint even get the ip for containers. (can ping from (centos vm) to internet)
I’ve tried creating bridge in centos and used this command
" * lxc config device add test eth0 nic nictype=bridged name=eth0 parent=enpos3"
In this case i can ping from vm to container and vice versa but not able to ping from containers vice versa

Note : am using laptop over wifi


Ah, with Wifi you’re going to be screwed unfortunately.

Wifi is per-MAC authentication so you cannot bridge to a wifi network, at least not a wifi network that has any kind of security on it (WEP/WPA).

Any suggestion to run LXD Containers in my home lab?

For Wifi, you don’t have a ton of options when it comes to having other systems on your network be able to access your containers.

The main one that comes to mind would be to run a normal LXD bridge (like lxdbr0) and then configure your home router to route the subnet of that bridge to the machine running it.

So say your laptop is at and your lxdbr0 has, you’d put a route in your home router for via

This should then allow everything else on your network which communicates through your router to reach instances on that network.

The obvious downside of this approach is that it’s quite manual, you’ll need to do that for every system that’s hosting LXD instances and if you move an instance between machine, then its address will be completely different.

Hi Stephane

Ignore if it is dumbass doubt, as per what you said per-MAC authentication doesent allow ip from router, but my router dhcp table has listed my containers ip/hostname.

but still not able to ping from cointainer to internet or gateway and vice versa.
any suggestions…


If you’re happy to use statically assigned IPs in your containers (rather than DHCP), then you could use the routed NIC type as this will allow you to assign an instance an IP on your main LAN when using a WIFI adapter as the parent interface.