Introduction

I initially wanted to add a search domain property to my Debian workstation to allow DNS resolution using only hostnames within my lab. On servers this can be as simple as adding the appropriate settings to /etc/resolv.conf

This was not the case for my workstation. Many modern Linux desktop environments use NetworkManager to manage the network connection properties. Few will have the option to define a DNS search domain in the GUI.

Thankfully, NetworkManager has CLI tools to adjust parameters including those that are not available via the desktop GUI. The tool in question - nmcli or the simpler nmtui with a shell GUI.

  • Tested with Gnome v48 running on Debian 13 (Trixie).

NMCLI

Running nmcli without options will show the current basic configuration

sudo nmcli

enp5s0: connected to Wired connection 1
        "Realtek RTL8111/8168/8211/8411"
        ethernet (r8169), 30:9C:23:A1:AC:F9, hw, mtu 1500
        ip4 default
        inet4 192.168.0.12/24
        route4 192.168.0.0/24 metric 100
        route4 default via 192.168.0.1 metric 100
        inet6 fe80::96fc:e162:8601:2db8/64
        route6 fe80::/64 metric 1024

lo: connected (externally) to lo
        "lo"
        loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536
        inet4 127.0.0.1/8
        inet6 ::1/128

DNS configuration:
        servers: 192.168.0.109
        domains: searchdomain.tld
        interface: enp5s0

An abridged listing can be obtained with:

sudo nmcli con show

NAME                UUID                                  TYPE      DEVICE 
Wired connection 1  5dc7c806-85e0-3306-a07c-33d82833caca  ethernet  enp5s0 
lo                  ba07892f-795e-45c9-9730-0c709a7e322f  loopback  lo  

Add a search domain of searchdomain.tld with:

sudo nmcli con mod 'Wired connection 1' ipv4.dns-search "searchdomain.tld"

View the configured search domain with:

sudo nmcli con show 'Wired connection 1' | grep dns-search  

Manual Configuration

You can of course, also add a search domain by editing the appropriate configuration file, adding an dns-search entry.

sudo nano /etc/NetworkManager/system-connections/'Wired connection 1.nmconnection'
[connection]
id=Wired connection 1
uuid=5dc7c806-85e0-3306-a07c-33d82833caca
type=ethernet
autoconnect-priority=-999
interface-name=enp5s0
timestamp=1756211070

[ethernet]

[ipv4]
dns=192.168.0.109;
dns-search=searchdomain.tld;
ignore-auto-dns=true
method=auto

[ipv6]
addr-gen-mode=default
method=auto

[proxy]

and restarting the NetworkManager daemon.

sudo systemctl restart NetworkManager