weixin_39673742
weixin_39673742
2021-01-07 08:51

DHCP is not working if ip address range was entered during initial bridge creation in lxd init.

The template below is mostly useful for bug reports and support questions. Feel free to remove anything which doesn't apply to you and add more information where it makes sense.

Required information

  • Distribution: Ubuntu
  • Distribution version: 16.04
  • The output of "lxc info" or if that fails: driver: lxc driver_version: 2.1.0 kernel: Linux kernel_architecture: x86_64 kernel_version: 4.10.0-35-generic server: lxd server_pid: 12551 server_version: "2.18" storage: zfs storage_version: 0.6.5.9-2

Issue description

DHCP is not working if ip address range (eg. 10.10.1.1/24) was entered during lxd init when asking for bridge creation.

During lxd init, i entered ipv4 address range for bridge setup and left ipv6 to 'auto'. After that, i tried to create a container. ipv6 was successfully assigned by dhcp but not ipv4.

Steps to reproduce

  1. lxd init
  2. during bridge creation, enter ip address for ipv4 instead of setting to auto.
  3. create a container.

该提问来源于开源项目:lxc/lxd

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

7条回答

  • weixin_39673742 weixin_39673742 4月前

    Hi ,

    The requested information as follow.

    Thanks for your reply.

    image

    image

    image

    image

    点赞 评论 复制链接分享
  • weixin_39688875 weixin_39688875 4月前

    That's odd, this seems to indicate everything functioning properly... Can you confirm you have the DHCP client running inside the container and if so, paste the content of /var/log/syslog from the host, the dnsmasq messages should be of particular interest.

    点赞 评论 复制链接分享
  • weixin_39688875 weixin_39688875 4月前
    
    root:~# lxd init
    Do you want to configure a new storage pool (yes/no) [default=yes]? 
    Name of the new storage pool [default=default]: 
    Name of the storage backend to use (dir, btrfs, lvm, zfs) [default=zfs]: 
    Create a new ZFS pool (yes/no) [default=yes]? 
    Would you like to use an existing block device (yes/no) [default=no]? 
    Size in GB of the new loop device (1GB minimum) [default=43GB]: 
    Would you like LXD to be available over the network (yes/no) [default=no]? 
    Would you like stale cached images to be updated automatically (yes/no) [default=yes]? 
    Would you like to create a new network bridge (yes/no) [default=yes]? 
    What should the new bridge be called [default=lxdbr0]? 
    What IPv4 address should be used (CIDR subnet notation, “auto” or “none”) [default=auto]? 10.10.1.1/24
    Would you like LXD to NAT IPv4 traffic on your bridge? [default=yes]? 
    What IPv6 address should be used (CIDR subnet notation, “auto” or “none”) [default=auto]? 
    LXD has been successfully configured.
    root:~# lxc launch ubuntu:16.04 test
    If this is your first time using LXD, you should also run: lxd init
    To start your first container, try: lxc launch ubuntu:16.04
    
    Creating test
    Starting test                               
    root:~# lxc list
    +------+---------+--------------------+-----------------------------------------------+------------+-----------+
    | NAME |  STATE  |        IPV4        |                     IPV6                      |    TYPE    | SNAPSHOTS |
    +------+---------+--------------------+-----------------------------------------------+------------+-----------+
    | test | RUNNING | 10.10.1.176 (eth0) | fd42:b210:18b8:6998:216:3eff:fe8c:2cb5 (eth0) | PERSISTENT | 0         |
    +------+---------+--------------------+-----------------------------------------------+------------+-----------+
    root:~# 
    

    Unable to reproduce this issue with the instructions above.

    点赞 评论 复制链接分享
  • weixin_39807896 weixin_39807896 4月前

    Had the same issue. Looks like it happens if you create the container before setting up the network. After the bridge is created, all new containers are happy. Containers existing before the bridge don't get assigned an IPV4 Address.

    点赞 评论 复制链接分享
  • weixin_39688875 weixin_39688875 4月前

    that would certainly be true if you're using LXD 2.0.x (2.0.10 or 2.0.11 these days) as prior to LXD 2.3 (I think) we were doing IPv6 link-local connectivity by default until a network was properly configured.

    This was communicated to the containers at the time they were created, leading to persistent network configuration in those containers. That means that configuring the bridge would indeed only lead to the right network configuration for new containers, not for the existing ones. In this case, you can manually edit /etc/network/interfaces (or files in /etc/network/interfaces.d) to manually re-enable IPv4 DHCP by changing "iface eth0 inet manual" to "iface eth0 inet dhcp".

    This is however unrelated to the issue that was reported here as this issue is specifically on much more recent versions of LXD which wouldn't suffer from this issue. An unconfigured LXD 2.3+ would show you a warning on container startup that network isn't configured, the container would then be entirely missing its eth0 device. Once the network is properly configured through "lxd init" or manually with "lxc network", restarting the container would then have it get an eth0 device and have it run DHCP on it as usual.

    点赞 评论 复制链接分享
  • weixin_39688875 weixin_39688875 4月前

    Also: - ifconfig lxdbr0 - ps aux | grep dnsmasq

    点赞 评论 复制链接分享
  • weixin_39688875 weixin_39688875 4月前

    Can you show the output of "lxc network show lxdbr0"?

    点赞 评论 复制链接分享