LXD with multiple NICs

Hi, I have a server with two physical NICs and want one container to run a nginx reverse proxy to connect to web servers in other containers attached to the other NIC.

I have run:

lxc config device add nginx eth0 nic nictype=routed parent=eno7 ipv4.address=185.32.222.xxx
lxc config device add nginx h80ngx proxy listen=tcp:185.32.222.xxx:80 connect=tcp: nat=true
lxc config device add nginx h443ngx proxy listen=tcp:185.32.222.xxx:443 connect=tcp: nat=true

I have tried with and without nat.

I can reach the web server from outside, but the container doesn’t have internet connection because there is no network defined inside the container as revealed by ip route show coming back empty.

When I tried to ip route add default via ... it gave me a local IP:

default via dev eth0 dev eth0 scope link

How can I make this work?



Please see here, LXD is no longer part of the Linux Containers project
This discussion forum provides support for Incus, which is a continuation of LXD.

You can migrate from LXD to Incus. There are also some user tutorials.