[lxc-users] Forwarding DNS requests to the host /etc/hosts file

Mark Constable markc at renta.net
Thu Jun 1 01:49:06 UTC 2017


On 01/06/17 02:34, Adil Baig wrote:
>> lxc config device add mycontainer etchosts disk path=/etc/hosts
>> source=/etc/hosts
>
> 1. Is very cool! I tried it and it works.

Yes, a good hint to know about, thanks simplyadilb.

> I am more interested in 2. as it seems more future proof when we move
> away from simple hosts file. Any suggestions on how to configure an
> internal dns. Do I need to start another instance for dnsmasq? Can I
> reuse the default? How would the container relay DNS requests to the
> host?
What I do on my internal testing LAN is to setup one container with a
real DNS server (pdns + pdns_recursor) with a web frontend and I point
ALL my local computers and containers /etc/resolv.conf to this nameserver
and control all local LAN DNS resolution in one place. Because pdns can
use a MySQL backend I intend to inject entries directly into the domains
and records tables during container setup.

One thing I found is that it's quite feasible to "masquerade" a real
domain with internal LAN IPs so that containers can resolve each other
directly via LAN IPs yet the rest of world sees that domain as pointing
to my external router IP.


More information about the lxc-users mailing list