Nameserver and domai

Good Morning,

I have mounted a server with LXD 3.19 and I need to know how to assign the name and domain search servers at the bridge level (from which all the containers hang), I understand that it works via dnsmasq but I do not quite know how to do it because although I add it by hand in the file /etc/resolv.conf but every x time it resets and breaks all the service of the containers.

Thanks greetings!

Hi!

If the network is managed by LXD (see lxc network list), then you can use dns.domain, as shown in https://github.com/lxc/lxd/blob/master/doc/networks.md

If it is managed by LXD, the dn.domain from where it should be put.

Thanks for your help simos as always!

you can learn how to use the client mostly by using --help

lxc network --help
(...)
  edit           Edit network configurations as YAML
  get            Get values for network configuration keys
(...)

lxc network edit lxdbr0
(...)
config:
  ipv4.nat: "true"

lxc network get --help

Usage:
  lxc network get [<remote>:]<network> <key> [flags]

so:

lxc network get lxdbr0 ipv4.nat
true

and:

lxc network set lxdbr0 dns.domain=....

should do the trick.
or you can edit the yaml config directly.

And with the servername?

well the host name is by default the container name.
When you use the default LXD config (lxdbr0 and dnsmasq) the containers get their names from their own config and these names are reflected in the dns (dnsmasq).

The problem is that the containers don’t know how to solve the names because the file

/etc/resolv.conf

of the host machine loses the configuration of this file.

If you use the default LXD configuration the containers resolve their names without using the resolv.conf of the host in any way, that is a container c1 can ping a container c2 without any use of this resolv.conf file.

That solves the problem is when I ping the host machines or containers

Sorry I don’t understand what you are saying here.

The problem is that since the machine hosts the containers I lose the configuration of the file /etc/resolv.conf, therefore the containers lose the possibility of resolving the names from outside (other physical servers of the company etc …)

With default LXD configuration, the LXD dns server (dnsmasq) uses the host default resolution configuration to ask for names it does not know by itself (that is, every host in the world except the containers it is managing).
When using default LXD config, it works pretty fine and any container can ping, say, www.google.com without problem.
If from the host you can’t ping the other computers, LXD dnsmasq will not be able to do that even with default LXD configuration.
Edit: the hosts file of the host can be a special case and you should test using the dig tool.

And what could be the reason why the host deletes its configuration from the /etc/resolv.conf file?

I have no idea. Local resolution is a complex matter and vary from a distro to another and even with the configuration options. Personally I never edit resolv.conf and it always has the same content (it’s set by systemd resolver). Without you being more specific it’s not possible to go further, I have not great urge to speculate on a million different use cases.