How to create routed network?

Hi, I’m trying to create a routed network with two routers using LXD. The routers need to be able to talk to each other and do not need to access the internet. And on each lan I will have multiple vm’s and test my apps from end-to-end.

I’m trying to do the following:

lan1 – router1 — router2 – lan2

Can someone help out w/ what commands I need to do that. I’m not sure what network type to use. I think ovn is the type? Any guidance would be helpful. Thanks.

Hi, I assume that your routers are lxd guests, and you want them to manage your network, not lxd itself. I also assume that you are using single non-clustered lxd host.

Create 3 bridged networks:

lxc network create lan1 ipv4.address=none ipv6.address=none
lxc network create lan2 ipv4.address=none ipv6.address=none
lxc network create routers ipv4.address=none ipv6.address=none

Create profiles:

lxc profile create p-router1
lxc profile create p-router2
lxc profile create p-client1
lxc profile create p-client2

Add storage and network devices to profiles:

lxc profile device add p-router1 root disk path=/ pool=<storage-name>
lxc profile device add p-router1 lan1 nic name=enp5s0 network=lan1
lxc profile device add p-router1 routers nic name=enp6s0 network=routers
lxc profile device add p-router2 root disk path=/ pool=<storage-name>
lxc profile device add p-router2 lan2 nic name=enp5s0 network=lan2
lxc profile device add p-router2 routers nic name=enp6s0 network=routers
lxc profile device add p-client1 root disk path=/ pool=<storage-name>
lxc profile device add p-client1 lan1 nic name=enp5s0 network=lan1
lxc profile device add p-client2 root disk path=/ pool=<storage-name>
lxc profile device add p-client2 lan2 nic name=enp5s0 network=lan2

create and start Instances:

lxc launch <image-name> router1 --profile p-router1
lxc launch <image-name> router2 --profile p-router2
lxc launch <image-name> client1 --profile p-client1
lxc launch <image-name> client2 --profile p-client2

Now you need to do manual configuration of ip addresses and route tables from inside of your routers.
Have fun :smile:

Thank you very much for this! Very helpful in my understanding of how to use LXD.