LXD: Issue overriding ipv4.address from eth0 profile

networking
lxd

(Jonathon) #1

Good afternoon,

I’m having an issue overriding the ipv4 address on a container that inherits a default eth0 profile. Current LXC` version is 3.13. Below are the steps I took to set the ipv4 address.

~ % lxc list plexContainer                                                                                                                
+---------------+---------+------+------+------------+-----------+
|     NAME      |  STATE  | IPV4 | IPV6 |    TYPE    | SNAPSHOTS |
+---------------+---------+------+------+------------+-----------+
| plexContainer | STOPPED |      |      | PERSISTENT | 1         |
+---------------+---------+------+------+------------+-----------+
~ % lxc config show plexContainer
architecture: x86_64
config:
  image.architecture: amd64
  image.description: ubuntu 18.04 LTS amd64 (release) (20181206)
  image.label: release
  image.os: ubuntu
  image.release: bionic
  image.serial: "20181206"
  image.version: "18.04"
  volatile.base_image: 84a71299044bc3c3563396bef153c0da83d494f6bf3d38fecc55d776b1e19bf9
  volatile.idmap.base: "0"
  volatile.idmap.current: '[{"Isuid":true,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.idmap.next: '[{"Isuid":true,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.last_state.idmap: '[{"Isuid":true,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.last_state.power: STOPPED
devices: {}
ephemeral: false
profiles:
- default
- sshKey
- autosnapshot
- mediaDrives
stateful: false
description: ""
~ % lxc profile add plexContainer eth0
Profile eth0 added to plexContainer
~ % lxc config device override plexContainer eth0 ipv4.address=192.168.20.5
Device eth0 overridden for plexContainer
~ % lxc config show plexContainer
architecture: x86_64
config:
  image.architecture: amd64
  image.description: ubuntu 18.04 LTS amd64 (release) (20181206)
  image.label: release
  image.os: ubuntu
  image.release: bionic
  image.serial: "20181206"
  image.version: "18.04"
  volatile.base_image: 84a71299044bc3c3563396bef153c0da83d494f6bf3d38fecc55d776b1e19bf9
  volatile.eth0.hwaddr: 00:16:3e:f5:c9:ec
  volatile.eth0.name: eth0
  volatile.idmap.base: "0"
  volatile.idmap.current: '[{"Isuid":true,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.idmap.next: '[{"Isuid":true,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.last_state.idmap: '[{"Isuid":true,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.last_state.power: STOPPED
devices:
  eth0:
    ipv4.address: 192.168.20.5
    nictype: macvlan
    parent: vlan0
    type: nic
ephemeral: false
profiles:
- default
- sshKey
- autosnapshot
- mediaDrives
- eth0
stateful: false
description: ""
~ % lxc start plexContainer
~ % lxc list plexContainer
+---------------+---------+-----------------------+------+------------+-----------+
|     NAME      |  STATE  |         IPV4          | IPV6 |    TYPE    | SNAPSHOTS |
+---------------+---------+-----------------------+------+------------+-----------+
| plexContainer | RUNNING | 192.168.20.212 (eth0) |      | PERSISTENT | 1         |
+---------------+---------+-----------------------+------+------------+-----------+

The eth0 profile is as follows

~ % lxc profile show eth0
config: {}
description: Adds the container to the lxd vlan.
devices:
  eth0:
    nictype: macvlan
    parent: vlan0
    type: nic
name: eth0

Any help or insight is greatly appreciated!!

Thanks,
Jonathon


#2

check out the doc
Scroll down until ‘ipv4.address’. You shall see in the fifth column (used by) the values (bridged, ipvlan). So I think that it means LXD does not manage IP address for macvlan.


(Stéphane Graber) #3

Correct, ipv4.address and ipv6.address control what address to give over DHCP when LXD manages the DHCP server OR in the case of ipvlan defines what address to take on the existing subnet.

For other types, the option is meaningless.


(Jonathon) #4

Thank you both for the quick replies. I can’t believe I had forgotten that, and hadn’t thought to check. Are there pros/cons to either bridge/ipvlan. I’m not familiar with the latter. From what I can tell configuration of ipvlan appears to be more straightforward. That being said when I try to set a container up using a modified profile of the above to nictype: ipvlan I get the following error:

Error: Initialize LXC: LXC is missing one or more API extensions: network_ipvlan, network_l2proxy, network_gateway_device_route

Thoughts?


#5

Ipvlan is a recent addition to LXD 3.13. Currently it is only available from LXD as found in the edge channel of the LXD snap package. Which means that if you want to use it now, you need to make a decision whether to switch to the daily updated LXD. See the other thread here on LXD 3.13 which has a discussion on ipvlan.


(Jonathon) #6

I’m currently on LXD 3.13 though. Is there two separate 3.13 releases? IE stable/edge 3.13.


(Thomas Parrott) #7

Did you build your lxd from source? You also need lxc from master as that is where the bulk of the ipvlan functionality is. That is what those errors mean, that your lxc version is missing required functionality.


#8

For ipvlan functionality, there is need for a LXD package that has both lxd 3.13 and liblxc 3.1.1. The current LXD snap package from the stable channel only has lxd 3.13 and liblxc is at the older 3.1.0 version.

If you really need to try ipvlan now, you need to switch to another channel. The edge channel is OK, and I am using it now. However, the edge channel is updated daily, therefore it is not recommended to use this in production.

See also my replies in the announcement of LXD 3.13 for more details and also how to use ipvlan, https://discuss.linuxcontainers.org/t/lxd-3-13-has-been-released/

Having said all that, ipvlan will likely take a little bit more to be made available in the stable channel.