I remember that it is possible to set up DNS (some dns server somewhere) so that every LXD container of your host (eg one named alex) is accessible as .lxd
I remember it’s possible, because I have set it up on my old computer like that. But nomatter how much I search, I cannot find how to do it on my new LXD 3.0 (snap version).
Can you please show me how?
Can you please write this information in LXD’s documentation site? I don’t know for sure, but it sounds like very useful information to me.
Ubuntu 16.04 uses dnsmasq-base and it’s easy to configure an additional (prepended) DNS server, with LXD’s DNS server. You can find instructions on this if you search a bit on this forum.
However, Ubuntu 18.04 uses instead systemd-resolve as the DNS client. Therefore, you need to specify a la systemd the network configuration that you want for lxdbr0.
However, even though I’ve reboot countless times, I get this, as if the .network files are not being read at all:
root@karjala-vmware:~# systemd-resolve --status lxdbr0
Link 3 (lxdbr0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
I am getting some improvement, when I restart systemd-networkd. Rebooting is not enough, I have to explicitly type this afterwards, every time:
karjala@karjala-vmware:~$ sudo systemctl restart systemd-networkd
karjala@karjala-vmware:~$ systemd-resolve --status lxdbr0
Link 3 (lxdbr0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 10.123.194.1
DNS Domain: lxd
But still, I’m getting no dns resolution of alex.lxd:
karjala@karjala-vmware:~$ host alex.lxd
Host alex.lxd not found: 3(NXDOMAIN)
karjala@karjala-vmware:~$ sudo su -
root@karjala-vmware:~# systemctl restart systemd-resolved.service
root@karjala-vmware:~# host alex.lxd
Host alex.lxd not found: 3(NXDOMAIN)
Also before restarting systemd-networkd, the command dig @10.123.194.1 alex.lxd returns the correct result immediately. However after restarting it, the above dig command hangs until timeout. It looks like the problems are too many. I don’t know what’s wrong. The system is very fresh.
This should work, so the problem would be with the first half of the setup on the host.
I have not tested my tutorial with the LXD snap, so there might be something there. Cannot think of something specific yet.
The most probably would be an issue with systemd-networkd. It does many things automatically so it either works fine or does not work at all. One issue with systemd-networkd is that if a DNS server does not respond early enough, then it’s not used later. But the configuration should be picked up.
I have set up a LXD container with 18.04 (ubuntu:18.04), enabled nesting, set up the LXD snap in the container, and then created a nested container with 18.04 (ubuntu:18.04).
I did the configuration in /etc/systemd/network/lxd.network and then restarted the container.
I was able to ping the nested container, so it worked for me.
I cannot think of a reason why it should not work for your on the VMWare VM. There might be some (systemd?) race condition that did not show up in my case.
The Domains=lxd allows you to ping alex and it will work (because the DNS client will auto-append .lxd to make it ping alex.lxd.
The issue though with modifying /etc/systemd/resolved.conf is that (I think) you configure your whole system to use LXD’s DNS client for name resolutions.
It would be great if more people can try out the tutorial in order to figure out such cases and identify what troubleshooting to do.
Hi. I created another VM, this time with ordinary Ubuntu 18.04 Desktop, and the same thing happened, as I had with Ubuntu MATE.
So it very well might not be the fault of my virtual machines. I’ll test your tutorial in a pure system, without VMware, when my new laptop arrives, in 2-3 weeks.
As shown in my tutorial, you should get DNS in the Current scopes.
If you do not get DNS in the Current scopes, then the issue is how to get DNS to appear there.
I tried on a laptop (upgrade to 18.04, not clean install) as well and could not get it to work either. The Scope would not show DNS.
Apparently, things work better inside LXD containers .
It worked?? Then that means that we are probably doing something different in our attempts to get it working. Because I also tried an Ubuntu under VMware and that hadn’t worked.
@simos , when you say your tutorial worked on your VM (under VirtualBox), did your VM run LXD as a snap or as an apt package? Because if your VM was Ubuntu Server (and not Ubuntu Desktop), you would have tested it with apt (which is not the recommended way, I believe).
I tested the snap way a few more times, on new VMs. It didn’t work. Then I tested an Ubuntu Server (this comes with LXD pre-installed as an apt package) - your method worked there.
So what did you try? I’m interested in the snap way, because that’s the recommended way.
I tried uninstalling the pre-installed LXD that Ubuntu Server has by default, and installing LXD there from snap. Also did lxd init.
This time, when I tried your solution, the “systemd-resolve --status” command showed a DNS server in lxdbr0, but when I did lxc list, the IPv4 adderss of alex container was empty (alex only had an IPv6 address), and host alex.lxd didn’t return anything.
Whenever I removed the lxd.network file from /etc/systemd/network, alex would get an IPv4 after rebooting, but, of course, the host would still not be able to execute “host alex.lxd”
It seems Ubuntu Server and Ubuntu Desktop are behaving differently.
What was your setup when you said that it all worked?