wishlist: connect to lxc container by name using avahi

Bug #824167 reported by Sidnei da Silva
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxc (Ubuntu)
Won't Fix
Wishlist
Unassigned

Bug Description

Would be really nice to be able to 'ssh <container>.local' by using avahi-daemon to advertise the container.

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

The templates tweak dhclient.conf so that the container should send its hostname. If you have dnsmasq running (i.e. if you are connecting your clients to a libvirt bridge), and your host has 'nameserver 192.168.122.1' at the top, then you should be able to 'ssh <container>.'.

Since lxc is not setting up your network environment, I'm not sure that it is proper for lxc itself to do any more. Does the above work for you?

Revision history for this message
Sidnei da Silva (sidnei) wrote :

Apparently that doesn't work. I modified the host's dhclient.conf to add:

   prepend domain-name-servers 192.168.122.1;

Such that /etc/resolv.conf now contains:

  nameserver 192.168.122.1
  nameserver 10.0.1.1

dnsmasq seems to be running:

   1366 dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/default.pid --conf-file= --except-interface lo --listen-address 192.168.122.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-lease-max=253 --dhcp-no-override

Interestingly, seems like there's no route to the 192.168.122.0 network on the host, so maybe something is broken on my side:

route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 virbr0
0.0.0.0 10.0.1.1 0.0.0.0 UG 0 0 0 eth1
0.0.0.0 0.0.0.0 0.0.0.0 U 1004 0 0 virbr0

Revision history for this message
Sidnei da Silva (sidnei) wrote :

After a reboot, this is now working!

May I change the suggestion to use avahi to instead modify the host's dhclient.conf as I done above instead? Or maybe you can come up with a better way to do it.

Revision history for this message
Serge Hallyn (serge-hallyn) wrote : Re: [Bug 824167] Re: wishlist: connect to lxc container by name using avahi

Quoting Sidnei da Silva (<email address hidden>):
> After a reboot, this is now working!
>
> May I change the suggestion to use avahi to instead modify the host's
> dhclient.conf as I done above instead? Or maybe you can come up with a
> better way to do it.

I'm afraid I know nothing about avahi. Can you explain a bit more about
what you are suggesting?

IIUC your suggestion would be a good one, but should be done for libvirt.

Revision history for this message
Sidnei da Silva (sidnei) wrote :

Avahi is nothing more than a multicast-dns implementation. if avahi-daemon is installed in the container and libnss-mdns (IIRC) in the host, then the container will broadcast it's hostname through mdns and the host would be able to resolve it. It might be overkill however, specially since the dhclient/resolv.conf option works fine as you pointed out.

Changed in lxc (Ubuntu):
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Given comment #5, I am going to mark this 'wontfix', as its a clever idea that seems like overkill.

If someone wants to write the patch to do this I won't be opposed.

Changed in lxc (Ubuntu):
status: Confirmed → Won't Fix
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.