I want to start using lxc container on an Ubuntu 16.04 Xenial machine. I am using lxd 2.21 from the xenial-backports repository. It works fine up to the point where I want to give my containers network access.
I want to create a new bridge device which should NAT all connections to the internet using the command lxc network create lxdnatbr0
. This command yields the error message
error: Failed to run: dnsmasq --strict-order --bind-interfaces --pid-file=/var/lib/lxd/networks/lxdnatbr0/dnsmasq.pid --except-interface=lo --interface=lxdnatbr0 --quiet-dhcp --quiet-dhcp6 --quiet-ra --listen-address=10.95.139.1 --dhcp-no-override --dhcp-authoritative --dhcp-leasefile=/var/lib/lxd/networks/lxdnatbr0/dnsmasq.leases --dhcp-hostsfile=/var/lib/lxd/networks/lxdnatbr0/dnsmasq.hosts --dhcp-range 10.95.139.2,10.95.139.254,1h --listen-address=fd42:2c73:3326:bbb7::1 --enable-ra --dhcp-range ::,constructor:lxdnatbr0,ra-stateless,ra-names -s lxd -S /lxd/ --conf-file=/var/lib/lxd/networks/lxdnatbr0/dnsmasq.raw -u lxd: dnsmasq: failed to create listening socket for 10.95.139.1: Address already in use
At this point, I have three other dnsmasq processes running. Two are coming from libvirt, one from the NetworkManager:
$ ps ax|grep dnsmasq
3576 ? S 0:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
3577 ? S 0:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
5525 ? S 0:00 /usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/var/run/NetworkManager/dnsmasq.pid --listen-address=127.0.1.1 --cache-size=0 --conf-file=/dev/null --proxy-dnssec --enable-dbus=org.freedesktop.NetworkManager.dnsmasq --conf-dir=/etc/NetworkManager/dnsmasq.d
11318 pts/1 S+ 0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn dnsmasq
At first I assumed, that it was the fault of libvirt, which had another dnsmasq process running. But even when I stopped that, another dnsmasq process started by the NetworkManager remained.
Does someone know, how I can make this work?
The error message says:
When you create a new network with
lxc network create
, LXD spawns a newdnsmasq
process for you, a process that binds to the new interface and only that.It is weird that it complains that the address is already in use, because the new
dnsmasq
is on a separate independent interface. To make sure there is no race condition, tryand then create it again.
If it does not work, run
in order to get a list of all
dnsmasq
processes.