linuxcontainers.org icon indicating copy to clipboard operation
linuxcontainers.org copied to clipboard

Mention lxd-p2c in getting started

Open danboid opened this issue 6 years ago • 3 comments

Having spent a few weeks getting to grips with the basics of lxd, I have a couple of suggested additions /improvements that could be made to the lxd getting started guide ( https://linuxcontainers.org/lxd/getting-started-cli/ ) that would've saved me days or weeks of troubleshooting, searching and experimentation.

The first is in respect to lxd networking, specifically the bridge configuration. After days spent reading the lxd forums and trying many configs, I finally worked out why I couldn't get networking to work in any of my containers. It turns out that you have to explicitly disable IPv6 in the lxdbr0 configuration for both NAT and addressing or else it breaks any IPv4 only hosts networking. This may seem obvious but it really isn't and I didn't see this suggested in any of the related lxd blog or forum posts I found and nor was this suggested to me by anyone in the lxcontainers IRC channel.

I would recommend either modifying/extending the Initial configuration section of the getting started guide to cover this or adding a new networking section immediately after that section of the guide that would read something like this:


LXD networking

In order for your lxd containers to get network access, a bridged network device has to be created on your lxd host, this device (usually called lxdbr0) has to be attached to an lxd profile (usually 'default') and this profile needs to be added to your container(s) so that they can access the network. Running lxd init and answering yes when asked about creating a new local network bridge will do nearly all of the required configuration to enable networking for lxd but your IPv4 hosts won't work unless you specifically tell lxd to disable IPv6 NAT and addressing in your bridge configuration.

To disable IPv6, presuming you used lxd init to create a bridged interface called lxdbr0, you would run the command:

# lxc network edit lxdbr0

Then edit it so that the bridge configuration looks something like this:

config:
  ipv4.address: 146.87.119.1/24
  ipv4.nat: "true"
  ipv6.address: none
  ipv6.nat: "false"
description: ""
name: lxdbr0
type: bridge
used_by:
- /1.0/containers/test
managed: true
status: Created
locations:
- none

There is usually no need to restart any containers after changing your lxd host network settings, the changes are applied instantly.


The other addition I would suggest adding to the getting started guide is that it makes no mention of lxd-p2c to ease the process of creating containers from existing servers. I posted a short guide on the usage of lxd-p2c on the forums here https://discuss.linuxcontainers.org/t/howto-use-lxd-p2c/3574/3

Thanks

danboid avatar Jan 08 '19 10:01 danboid

Moving over to the right repo.

I don't understand your IPv6 point though. There is no problem with having a container get an IPv6 address when the host doesn't have IPv6, this simply leads to an IPv6 connection failure (no route to host) and immediately falls back to IPv4.

That's how pretty much all our users have it setup (since that's the default) and based on statistics, only 25% or so actually have public IPv6 routes available.

This suggests that something else was wrong on your system if that ended up preventing network connections.

stgraber avatar Jan 08 '19 15:01 stgraber

Yes you're right about the networking. I've removed the IP6 lines from my bridge config and its still working so it I must've got the subnet, address or something else wrong earlier.

My suggestion about adding a mention of lxd-p2c and linking to /including some documentation for it still stands, newcomers may think they have to do conversions fully manually or start afresh otherwise.

danboid avatar Jan 09 '19 09:01 danboid

Added this as a point to the todo list of #413 .

Maybe we could close this then, but it's up to you.

toby63 avatar Jun 25 '20 21:06 toby63