Set dns-nameserver via lxc command

Hi
I have some containers in different distributions
When I set external ip for my containers, my containers is accessible via external ip but my containers haven’t access to internet.

how can i set dns-nameserver for each container regardless of its distribution?
something like this: lxc config device set ct eth0 dns.name 8.8.8.8

You can use the raw.dnsmasq parameter for that, so “lxc config edit containername” and then add:

raw.dnsmasq: dhcp-option=option:dns-server,8.8.8.8

in the config section.

1 Like

dnsmasq is one way to do this. If you’ve got a static config, then you should just configure this inside the container or through cloud-init with the user.network-config mechanism.

1 Like