Make .lxc domain name resolution easier to discover and enable

Bug #1389954 reported by Forest on 2014-11-06
This bug affects 4 people
Affects Status Importance Assigned to Milestone
lxc (Ubuntu)

Bug Description

The lxc package on ubuntu does almost nothing to help a user enable DNS resolution for containers via dnsmaq, let alone discover that it is possible. How about enabling it by default? I think all it would take is adding server=/lxc/ to a file in /etc/NetworkManager/dnsmasq.d/ and uncommenting LXC_DOMAIN="lxc" in /etc/default/lxc-net.

Even if there's a good reason not to enable this by default, shouldn't it at least be clearly documented someplace obvious instead of buried in a system config file with a misleading comment that mentions the wrong dnsmasq file to edit? (The one currently mentioned by /etc/default/lxc-net does nothing on ubuntu desktop systems, because ubuntu's NetworkManager starts dnsmasq with a special config directory.)

Forest (foresto) on 2014-11-06
description: updated
description: updated
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in lxc (Ubuntu):
status: New → Confirmed
Serge Hallyn (serge-hallyn) wrote :

This has been discussed before. I definately want to make things work as cleanly as possible out of the box. There are a few problems with doing htis though, 1) networkmanager isn't the only place we'd need to do this (most "serious" lxc hosts probably don't run networkmanager), 2) if we do this automatically then changes made to /etc/default/lxc-net may start to require more baroque changes elsewhere. We almost want a simple tool to administer all the network bits at this point.

Another possiblity is to leave fixing this to lxd.

Changed in lxc (Ubuntu):
importance: Undecided → Wishlist
Forest (foresto) wrote :

Thanks for taking an interest in the issue.

Since I filed this specifically against lxc in Ubuntu, wouldn't it make sense to start by documenting the necessary config changes (including NetworkManager's dnsmasq config, since it is part of Ubuntu by default) in /usr/share/doc/lxc/README?

Would you care to upload a patch to edit README.Debian with that

Note that the non-network-manager version of this is currently commented
in .

Forest (foresto) wrote :

Sure. Is this the right place?

Serge Hallyn (serge-hallyn) wrote :

Yes, you might add debian/README.Debian there.

Forest (foresto) wrote :

Which branch?

Serge Hallyn (serge-hallyn) wrote :

I think dpm-vivid would be the right one.

Forest (foresto) wrote :

Okay, I've written up a short README.Debian describing the necessary changes to /etc/default/lxc-net and the dnsmasq config file. I don't remember what steps are necessary to make the domain names accessible, though, and I'd like to include those steps in the readme.

Do I have to restart the lxc-net service? (And is that service called the same thing regardless of whether sysv init, upstart, or systemd is in use?)

Do I have to restart NetworkManager?

Do I have to restart any already-running containers?

Serge Hallyn (serge-hallyn) wrote :

Yes, lxc-net is called lxc-net in all init systems where the job exists (syv, upstart, systemd)

Both lxc-net and network-manager need to be restarted (unless network-manager is smart and uses inotify to look for updates).

I don't believe containers would need to be restarted.

Forest (foresto) wrote :
Anton Statutov (astatutov) wrote :

Tried to follow the documentation on Ubuntu Server 15.04 with no luck. I have activated LXC_DOMAIN="lxc" in /etc/default/lxc-net, then created /etc/dnsmasq.conf and added server=/lxc/ (there is no NetworkManager installed). Tried to reboot, but still getting "ping: unknown host container.lxc". It seems that dnsmasq doesn't read the config.

Serge Hallyn (serge-hallyn) wrote :


personally in 15.10 I have

# Tell any system-wide dnsmasq instance to make sure to bind to interfaces
# instead of listening on
# WARNING: changes to this file will get lost if lxc is removed.

in /etc/dnsmaq.d/lxc

and it does work:

ping precise-gui.lxc
PING precise-gui.lxc ( 56(84) bytes of data.

experimancer (experimancer) wrote :

I'm on Ubuntu 16.04 LTS Server Edition (the host) and running some Trusty 14.04 LTS LXC-containers in it. Trying to get this DNS-name resolution working I added in /etc/default/lxc-net the line:

and in /etc/dnsmasq.d/lxc added the line:
server=/lxc/ stanza, then

1. stopped all existing containers
2. run 'sudo service lxc-net restart'
3. restarted the containers

but the DNS-name resolution does not work, e.g
"ping mycont.lxc" or
"dig @ mycont.lxc"
do not resolve to running LXC IP-address.

Whats wwong, how to get this working? Should I edit the LXC-configs somehow or is there some other dns/networking/resolv.conf/dnsmasq/iptables/etc configurations that I should check to debug why this is not working?

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers