LXC/LXD Macvlan

Manage LDX (Canonical documentation)

LDX containers (Ubuntu documentation)

From: HERE.

DHCP server from LXD (not a system DHCP server).
If you have some other DHCP server on your host, it may conflict with the one by LXD. So, show us the output of

lxc network list lxc network show lxd0 sudo lsof -i :53 (on the host)


Using Macvlan

Create a macvlan network

Use lxc network create <network_name> type=macvlan parent=<host_interface> to create a macvlan network. Replace <network_name> with a name for your network and <host_interface> with the name of your host's network interface (e.g., eth0).

Configure the container to use the macvlan network

Add the macvlan network to the container's configuration using lxc config device add <container_name> <device_name> nic nictype=macvlan parent=<network_name>. Replace <container_name>, <device_name>, and <network_name> with the appropriate values.

Assign a static IP address to the container

The container will now be able to obtain an IP address from your DHCP server or you can assign it a static IP address using lxc config device set <container_name> <device_name> ipv4.address=<container_ip>/<subnet_mask>.

Verify connectivity

You should now be able to access the container directly using its IP address on the public network.

Routing Considerations