<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jun 28, 2017 at 4:36 PM, Adil Baig <span dir="ltr"><<a href="mailto:simplyadilb@gmail.com" target="_blank">simplyadilb@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">In the new LXD (2.5+) is there automatic DNS resolution for containers on the host? <div><br></div></div></blockquote><div><br></div><div>It can. But you need to make it so.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div><div>I'd like to configure a virtual host on Apache (on the host mahcine) to proxy requests to a container using its DNS rather than its IP. How can i do this?</div></div>
<br></blockquote><div><br></div><div>(1) See <a href="https://stgraber.org/2016/10/27/network-management-with-lxd-2-3/">https://stgraber.org/2016/10/27/network-management-with-lxd-2-3/</a> . In particular:</div><div>- creating a new network bridge (or use lxdbr0, if you want)</div><div>- dns.domain and ipv4.address (for the bridge)</div><div>- (optional, if you want "static" ip for the container): "lxc network attach" and ipv4.address for the container</div><div><br></div><div>(2) configure the container to use DHCP. Dnsmasq will assign the appropriate IP based on the ip address you assign to the container in the previous step</div><div><br></div><div>(3) make sure you have dnsmasq installed on the host. Install it if you don't have it.</div><div><br></div><div>(4) make sure /etc/dnsmasq.d/lxd on the host exclude the interface created on step (1) (e.g. except-interface=lxdbr0)</div><div><br></div><div>(5) Create a file (I call mine /etc/dnsmasq.d/lxd-resolve), with this line (adjust IP and domain as necessary)</div><div><div>server=/lxd/<a href="http://10.0.3.1">10.0.3.1</a></div></div><div><br></div><div>(6) restart dnsmasq on the host if necessary</div><div><br></div><div>You can then refer to container using dns from the host</div><div><div># lxc list test</div><div>+------+---------+-------------------+------+------------+-----------+</div><div>| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |</div><div>+------+---------+-------------------+------+------------+-----------+</div><div>| test | RUNNING | 10.0.3.117 (eth0) | | PERSISTENT | 1 |</div><div>+------+---------+-------------------+------+------------+-----------+</div><div><br></div><div># ping -n -c 1 test.lxd<br></div><div>PING test.lxd (10.0.3.117) 56(84) bytes of data.</div><div>64 bytes from <a href="http://10.0.3.117">10.0.3.117</a>: icmp_seq=1 ttl=64 time=0.082 ms</div><div><br></div><div>--- test.lxd ping statistics ---</div><div>1 packets transmitted, 1 received, 0% packet loss, time 0ms</div><div>rtt min/avg/max/mdev = 0.082/0.082/0.082/0.000 ms</div></div><div><br></div><div><br></div><div>-- </div><div>Fajar</div></div></div></div>