Make .lxc domain name resolution easier to discover and enable

Bug #1389954 reported by Forest
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
lxc (Ubuntu)
Triaged
Wishlist
Unassigned

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/10.0.3.1 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)
description: updated
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

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

Changed in lxc (Ubuntu):
status: New → Confirmed
Revision history for this message
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
Revision history for this message
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?

Revision history for this message
Serge Hallyn (serge-hallyn) wrote : Re: [Bug 1389954] Re: Make .lxc domain name resolution easier to discover and enable

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

Note that the non-network-manager version of this is currently commented
in https://help.ubuntu.com/14.04/serverguide/lxc.html .

Revision history for this message
Forest (foresto) wrote :

Sure. Is this the right place?
https://github.com/lxc/lxc-pkg-ubuntu

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

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

Revision history for this message
Forest (foresto) wrote :

Which branch?

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

I think dpm-vivid would be the right one.

Revision history for this message
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?

Revision history for this message
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.

Revision history for this message
Forest (foresto) wrote :
Revision history for this message
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/10.0.3.1 (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.

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Hi,

personally in 15.10 I have

# Tell any system-wide dnsmasq instance to make sure to bind to interfaces
# instead of listening on 0.0.0.0
# WARNING: changes to this file will get lost if lxc is removed.
bind-interfaces
except-interface=lxcbr0
server=/lxc/10.0.3.1

in /etc/dnsmaq.d/lxc

and it does work:

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

Revision history for this message
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:
LXC_DOMAIN="lxc"

and in /etc/dnsmasq.d/lxc added the line:
server=/lxc/10.0.3.1 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 @10.0.3.1 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?

Changed in lxc (Ubuntu):
status: Confirmed → Triaged
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.