[lxc-users] Converting network from LXC to LXD

John Lane lxc at jelmail.com
Sat Dec 21 16:51:02 UTC 2019


On 20/12/2019 14:10, Fajar A. Nugraha wrote:
> 
> https://linuxcontainers.org/lxd/docs/master/containers#type-nic
> 
> So something like this for veth on a bridge (on "lxc config edit
> CONTAINER_NAME", in case you haven't figure it out):
> 
> devices:
>   eth0:
>     name: eth0
>     host_name: c1-0
>     nictype: bridged
>     parent: lxdbr0
>     type: nic
> 
> "parent" should be whatever the bridge is called on your host (lxd
> creates lxdbr0 by default).
> "host_name" is what the host side of the veth will be called (very
> useful if you're doing host-side traffic monitoring).
> 

Looking at nictype=bridged, I can set up DHCP addresses, thanks, but am
having difficulty with static configuration.

Looking at that document there seems to be no equivalent of the
following lxc configuration:

lxc.net.0.ipv4.address = 192.168.21.2/24
lxc.net.0.ipv4.gateway = 192.168.21.1

The "ipv4.address" entry documented as "An IPv4 address to assign to the
container through DHCP" and not as a CIDR address as per lxc.

I can't do this:

$ lxc config device set mycontainer eth0 ipv4.address 192.168.21.2/24
                                               Error: Invalid devices:
Invalid value for device option ipv4.address: Not an IPv4 address:
192.168.21.2/24

Also there appears to be no setting for gateway:

$ lxc config device set mycontainer eth0 ipv4.gateway 192.168.21.1
Error: Invalid devices: Invalid device option: ipv4.gateway

I can manually add them afterwards, i.e.

$ lxc exec mycontainer ip address add 192.168.21.2/24 dev eth0
$ lxc exec mycontainer ip route add default via 192.168.21.1 dev eth0

What am I missing? Can I assign static addresses with LXD configuration?


More information about the lxc-users mailing list