How to set DNS for a single container

Hello, I’m using Debian 13 (Stable) with Incus 7.0.1 (backports)

I try following commands (either for container or virtual machine). Guest takes expected IP address (DHCP client) but DNS is assumed to be bridge’s IP address (192.168.2.1):

$ incus network create -t bridge MyBridge1 ipv4.address=192.168.2.1/24 user.dns="1.1.1.1 8.8.8.8"
$ incus config set MyContainerName user.dns="1.1.1.1 8.8.8.8"
$ incus config set MyMachine user.network.dns=1.1.1.1

user.dns is for sure wrong user.X means for users and incus doesn’t care.

Bridge network - Incus documentation is the answer.

Thank you I partially reached my goal with this command:

$ incus network set MyBridge1 dns.nameservers=1.1.1.1,8.8.8.8

Now I need to know how to set different DNS nameserver per container when they share same network.

The bridge dns.nameservers setting applies to every guest on that network. For a different resolver per container, set it inside that guest rather than on the shared Incus network.

The easy answer is to have multiple incus networks (since they can have different DNS settings), and create your containers on the corresponding network.

The incus DHCP server is dnsmasq, which is minimal and lightweight - or not very well featured, whichever way you look at it.

If you want to give out different DHCP options to different clients on the same network, you’ll need a more heavyweight DHCP server like ISC KEA. And you will have to identify the clients somehow (e.g. by MAC address, or by some option in the DHCP client request)

In principle you could run your own DHCP server in its own container. I’m not entirely sure if you can turn off the incus-provided DHCP server on a given network; if you cannot, then simply use an unmanaged network (a bridge which you create on the host, e.g. with netplan)

However, you’d still be 100% responsible for managing DHCP entries for all your containers. I think it would likely be much less effort to apply static IP and DNS settings to all your containers, e.g. using cloud-init.

I wonder which problem @narcisgarcia is trying to solve.