2021-01-07 08:02

LXD initialization process with the lxd init command fails on ubuntu 17.04

Required information

About the VM:

  • Distribution: ubuntu
  • Distribution version: ubuntu 17.04 zesty
  • The output of "lxc info" (detailed output at: https://pastebin.com/WgLgXiYj)
  • Kernel version: 4.10.0-19-generic
  • LXC version: 2.12
  • LXD version: 2.12
  • Storage backend in use: zfs

About the host:

Distribution: Ubuntu Distribution version: Ubuntu 14.04.5 LTS Kernel version: 4.8.0

Issue description

On a fresh VM ( ubuntu 17.04 ) which is running on the host (ubuntu 14.04.5 LTS), I tried to start LXD initialization process using lxd init command. It resulted in an error.

Steps to reproduce

  1. Step one: Installed a new VM with ubuntu 17.04 on the host (ubuntu 14.04.5 LTS).
  2. Step two: Tried to configure LXD by starting the LXD initialization process with the lxd init command (as given below):

$> sudo apt-get install lxd
Reading package lists... Done
Building dependency tree       
Reading state information... Done
lxd is already the newest version (2.12-0ubuntu3).
0 upgraded, 0 newly installed, 0 to remove and 148 not upgraded.

$> sudo apt update
$> sudo apt install zfsutils-linux
$> sudo 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=18GB]: 
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]? 
What IPv6 address should be used (CIDR subnet notation, “auto” or “none”) [default=auto]? 

error: Failed to run: dnsmasq --strict-order --bind-interfaces --pid-file=/var/lib/lxd/networks/lxdbr0/dnsmasq.pid --except-interface=lo --interface=lxdbr0 --listen-address= --dhcp-no-override --dhcp-authoritative --dhcp-leasefile=/var/lib/lxd/networks/lxdbr0/dnsmasq.leases --dhcp-hostsfile=/var/lib/lxd/networks/lxdbr0/dnsmasq.hosts --dhcp-range,,1h --listen-address=fd42:f831:66be:8c25::1 --enable-ra --dhcp-range ::,constructor:lxdbr0,ra-stateless,ra-names -s lxd -S /lxd/ -u lxd: dnsmasq: failed to create listening socket for Address already in use

I think this error is the reason that a new container doesn't get any IP address.

Information to attach

/var/log/lxd/lxd.log https://pastebin.com/8cgfZ3Jm

lxc info https://pastebin.com/WgLgXiYj


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


  • weixin_39688875 weixin_39688875 4月前

    dnsmasq is started if the network has an ipv4.address or ipv6.address set.

    We could potentially expand the logic further to make it start only when really required, but it gets tricky pretty quickly as we'd want it on if any of those is true: - DHCPv4 is enabled - IPv6 is enabled (in any form as we need router advertisements) - DNS is enabled (we'd need a new dns.mode to completely turn DNS off)

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

    What about for setting option for network raw.dnsmasq port=0 According to manual Listen on instead of the standard DNS port (53). Setting this to zero completely disables DNS function, leaving only DHCP and/or TFTP

    then for restart dnsmasq - systemctl restart lxd right?

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

    Modifying raw.dnsmasq should immediately cause dnsmasq to be reloaded for you.

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

    This error means that you already have a DNS server binding all available IP addresses on your system.

    This usually points to a misconfigured dnsmasq or bind9 server on your system. Either configure those to bind just the IPs you care about, or if you don't need them at all, then uninstall them from your system.

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

    Thanks for the reply. Just adding to your reply: sudo apt-get remove --purge bind9 works

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

    what if i want to use bind/powerdns with dns resolver on host and dnsmasq only for local/private lxd networks with containers? I assigned static IPs to lxdbr0 but cannot create additional networks due to error: Address already in use

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

    That's fine, but you'll need to configure your bind/powerdns to only bind those network interfaces you want it on. Once you do that, there won't be a conflict anymore.

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

    Is it possible to disable dnsmasq for specific LXD networks ? I wonder what is a proper way to restart lxd/dnsmasq instances?

    点赞 评论 复制链接分享