On Wed, Jun 28, 2017 at 4:36 PM, Adil Baig <[email protected]> wrote:
> In the new LXD (2.5+) is there automatic DNS resolution for containers on > the host? > > It can. But you need to make it so. > 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? > > (1) See https://stgraber.org/2016/10/27/network-management-with-lxd-2-3/ . In particular: - creating a new network bridge (or use lxdbr0, if you want) - dns.domain and ipv4.address (for the bridge) - (optional, if you want "static" ip for the container): "lxc network attach" and ipv4.address for the container (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 (3) make sure you have dnsmasq installed on the host. Install it if you don't have it. (4) make sure /etc/dnsmasq.d/lxd on the host exclude the interface created on step (1) (e.g. except-interface=lxdbr0) (5) Create a file (I call mine /etc/dnsmasq.d/lxd-resolve), with this line (adjust IP and domain as necessary) server=/lxd/10.0.3.1 (6) restart dnsmasq on the host if necessary You can then refer to container using dns from the host # lxc list test +------+---------+-------------------+------+------------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +------+---------+-------------------+------+------------+-----------+ | test | RUNNING | 10.0.3.117 (eth0) | | PERSISTENT | 1 | +------+---------+-------------------+------+------------+-----------+ # ping -n -c 1 test.lxd PING test.lxd (10.0.3.117) 56(84) bytes of data. 64 bytes from 10.0.3.117: icmp_seq=1 ttl=64 time=0.082 ms --- test.lxd ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.082/0.082/0.082/0.000 ms -- Fajar
_______________________________________________ lxc-users mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-users
