# Incus Local DNS (A Pro Tip)

**URL:** https://discussion.scottibyte.com/t/incus-local-dns-a-pro-tip/718
**Category:** Uncategorized
**Created:** [February 21, 2026, 6:21pm UTC](https://discussion.scottibyte.com/t/incus-local-dns-a-pro-tip/718 "2026-02-21T18:21:30Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![scott](https://discussion.scottibyte.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@scott](https://discussion.scottibyte.com/u/scott)
#### Post date: [February 21, 2026, 6:21pm UTC](https://discussion.scottibyte.com/t/incus-local-dns-a-pro-tip/718/1 "2026-02-21T18:21:30Z")

</div>

Incus Containers do not implement local DNS by default. Here’s a simple fix.

Let’s start by creating a simple incus container.

```auto
incus launch images:ubuntu/24.04 Test

```

Move inside the container.

```auto
incus shell Test

```

I use Pi-hole to implement my local DNS and I have tutorials that discuss that.

 ![image](https://discussion.scottibyte.com/uploads/default/original/2X/7/71b15fd6360a7cc866fdde14c1cce44cb91cc31b.png)

If I try to resolve a local DNS name from inside of a container.

![image](https://discussion.scottibyte.com/uploads/default/original/2X/0/01b16285b790097beaf59b7c5850feb53e7c9659.png)

Resolving addresses on the public internet works fine.

![image](https://discussion.scottibyte.com/uploads/default/original/2X/b/b16d953d3d032c3e9001884d7cb2869afb4840b6.png)

Ubuntu hosts use systemd-resolved for DNS resolution and that is carried inside of an incus container on an Ubuntu Incus server.

 ![image](https://discussion.scottibyte.com/uploads/default/original/2X/1/1b4b757dd75b8f2d2870ba8803e19de7beaa7727.jpeg)

The systemd-resolved service uses a symbolic link to replace the resolv.conf file as a stub.

![image](https://discussion.scottibyte.com/uploads/default/optimized/2X/8/841da97bf3dbc4eba341f9bd1cccbc3b27ec6941_2_690x30.png)

The contents of that file clearly show that there is no local DNS resolution taking place. Notice that the only name server listed is a loopback address at 127.0.0.53.

 ![image](https://discussion.scottibyte.com/uploads/default/original/2X/3/3a0f74324a422e4970dd6206ecfd5809d3708618.jpeg)

To get around this, we are going to create a script that we can run which will add local DNS resolution to any existing incus container.

Exit the container shell back to your Incus server.

```auto
exit

```

Edit a file for the script.

```auto
nano ~/incusdns

```

Insert the following code.

```auto
#!/usr/bin/env bash
set -e

NAME="$1"

if [[-z "$NAME"]]; then
  echo "Usage: incusdns <container-name>"
  exit 1
fi

echo "Waiting for container '$NAME' to be ready..."
until incus exec "$NAME" -- true >/dev/null 2>&1; do
  sleep 0.5
done

echo "Applying local DNS to container: $NAME"

incus exec "$NAME" -- bash -c '
set -e
rm -f /etc/resolv.conf
cat > /etc/resolv.conf <<EOF
nameserver 172.16.0.10
nameserver 1.1.1.1
search incus
EOF
'

echo "DNS configured successfully in $NAME"

```

In the nameserver item above, replace my 172.16.0.10 with the address of your Pi-hole or other local DNS resolver on your network. Save the file with a CTRL O and Enter and then CTRL X to exit the nano editor.

The script deletes the file (and thus the systemd-resolved stub file) and creates a new file.

Give the script execute privilege.

```auto
chmod +x ~/incusdns

```

Create a bin folder in your home folder.

```auto
mkdir -p ~/bin

```

Provide a symbolic link to the script.

```auto
ln -s "$HOME/incusdns" "$HOME/bin/incusdns"

```

Add a path to the symbolic link in your .bashrc file.

```auto
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc

```

Execute your .bashrc to make the definition take effect now.

```auto
source ~/.bashrc

```

To change my Test container or any other container so it uses local DNS, just call the script with the container name where you want to enable local DNS.

```auto
incusdns Test

```

As a reminder, our Test container does not currently have local DNS resolution.

 ![image](https://discussion.scottibyte.com/uploads/default/original/2X/1/14bfb95b8a348adf69c7f3a44189ae0a78643dec.png)

Next, I run my script specifying my container name.

```auto
incusdns Test

```

 ![image](https://discussion.scottibyte.com/uploads/default/original/2X/8/8620bfb62d1d5ae062de317eda3b7dcdfa980902.png)

Now, when I go back into the container, the ping to my local DNS name works.

![image](https://discussion.scottibyte.com/uploads/default/original/2X/3/352d36c21d27a6a659b58daf12aa1cd4dc6d1e93.png)

Working local DNS name resolution from inside of an incus container can be very helpful for some applications. This is a simple way to achieve that.
