Error: Failed to create network 'lxdbr0': Failed to automatically find an unused IPv4 subnet, manual configuration required

Hi!

Here is the code that lxd init will use to find a random available IPv4 network,

You can see that it tries with 100 random subnets before it gives up.
For each randomly created network, it checks

  1. If the network is in the routing table
  2. If the network can be pinged

and does that for both IPv4 and IPv6.

Someone can add some print statements in the code to see where it fails (either the random networks are not random, either the check if the network is already in the routing table fails, either the pinging of the subnet has some weird issue and LXD gets replies from anything), either one of IPv4 or IPv6 is not available on the host.

The code that uses these functions is

so if you run lxd init, and press Enter all the way while there is no, for example, IPv6 support, then you get the error because in one of the Enters you select auto for IPv6.

lxd init can also accept a pre-seed file, therefore you can add there the network instead of asking LXD to find one randomly. Or, when you use the wizard lxd init, do not press Enter to accept auto but specify the network there. If, for example, there is no IPv6 support, type none instead.

Therefore, in your case, find the reason why auto fails in LXD init (network subnet configuration) for IPv4 and IPv6, and supply the appropriate values either at lxd init or with a LXD preseed file.

In the worst case, you can select none for the networking and then create the network later and finally add it to the lxd profile. In that way, you can get a nice 10.10.10.1 network.

2 Likes