DNS for LXC containers

  1. If your host is desktop Ubuntu, then it uses NetworkManager, which means you add a file like

     $ cat /etc/NetworkManager/dnsmasq.d/lxd
     server=/lxd/10.0.185.1
     server=/1.185.0.10.in-addr.arpa/10.0.185.1
    

    The IP 10.0.185.1 is the IP address that the LXD dnsmasq is listening on.

  2. If your host is Ubuntu server, then you need to install dnsmasq, and then configure your server’s dnsmasq to consult LXD’s dnsmasq (like before) for the IP range of your containers.
    The location to put the configuration file is

    $ cat /etc/dnsmasq.d-available/lxd
    # 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 lxd is removed.
    server=/lxd/10.0.185.1
    bind-interfaces
    except-interface=lxdbr0
    

    and then link that file to /etc/dnsmasq.d/lxd

4 Likes