frank
Goto Top

Linux NetworkManager - Adding a search domain using nmcli or nmtui

Actually, I just want to add my search domain to the network settings (search domain or dns search) under Arch-Linux and Fedora. This used to be very easy via Settings -> Network. Unfortunately, this was removed from the settings at some point. My environment is Gnome 43.3 and 46.

Like many other Linux distributions, my Arch or Fedora Linux is managed via the Network Manager. So this tip applies to all those who manage their network via NetworkManager (nmcli) (Ubuntu with ifupdown, Debian, Fedora, etc.).

The nmcli and nmtui commands are installed by default on both Linux systems. If you do not have at least nmcli installed, you are not using NetworkManager. You can use the nmcli for the "search domain" setting, or the simpler nmtui with a shell GUI.

Tested with:
  • Endeavor Arch Linux (Gnome 43.3)
  • Fedora 40, 41 (Gnome 46,47)

back-to-topnmcli


sudo nmcli con show
NAME                         UUID                                  TYPE      DEVICE 
Wired connection 1  7708dd93-ea55-398a-9dd1-b5be2c65d4b6  ethernet  enp4s0 
lo                           e6140168-f933-434b-883b-8095ee9b9488  loopback  lo     

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

With the command:
sudo nmcli con show 'Wired connection 1' | grep dns-search  
or
resolvectl
you can then check the settings.

Than restart the NetworkManager.

You can also change the configuration without using the nmcli command by simply editing the appropriate config file (e.g. using the vi editor):

vi /etc/NetworkManager/system-connections/'Wired connection 1.nmconnection'  

[connection]
id=Wired connection 1
uuid=c0718bbc-fa2b-3be2-a863-4d946ffa16ff
type=ethernet
autoconnect-priority=-999
interface-name=enp5s0
timestamp=1740436074

[ethernet]

[ipv4]
dns=192.168.0.1;
dns-search=searchdomain.tld;
method=auto

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

[proxy]
Simply change the 'dns-search=searchdomain.tld;' accordingly and restart the NetworkManager.

You must restart NetworkManager each time you make a change:
systemctl restart NetworkManager

back-to-topnmtui


Fedora Install:
sudo dnf install nmtui

Start nmtui:
[root@frank-endeavour ~]# nmtui

1) Select Edit connection
2) Select IPv4 configuration “Display”
3) Enter the relevant domain under “Search domains” and then select “OK”.

back-to-topUpdate for Ubuntu


In newer versions of Ubuntu, the Network Configuration Abstraction Layer Netplan runs to provide the network (from version 20.04 for a new installation). When upgrading, the old network configuration is simply carried over. Under 'Netplan', the file '/etc/network/interfaces' is unfortunately no longer available (ifupdown has been replaced by netplan).

This is the 'Search Domain' configuration under 'Netpan':

vi /etc/netplan/00-installer-config.yaml

network:
    ethernets:
        enp4s0:
            addresses:
            - 192.168.0.4/24
            dhcp4: false
            gateway4: 192.168.0.1
            nameservers:
                addresses:
                - 192.168.0.1
                search:
                - searchdomain.tld
    version: 2

followed by one:

sudo netplan generate
sudo netplan apply

That's all face-smile

Content-ID: 671377

Url: https://rootdb.com/tutorial/linux-networkmanager-adding-a-search-domain-using-nmcli-or-nmtui-671377.html

Printed on: March 26, 2025 at 10:03 o'clock

aqui
aqui Mar 16, 2025 at 08:07:51 (UTC)
Goto Top
You can use the nmcli for the "search domain" setting, or the simpler nmtui with a shell GUI
You can also edit your connection under /etc/NetworkManager/system-connections/ and add the dns-search command with the nano editor.
There are always many roads to Rome... face-wink
Frank
Frank Mar 16, 2025, updated at Mar 18, 2025 at 14:38:37 (UTC)
Goto Top
Yes, of course you can. I have added it above. The configuration will then look something like this (but I am a fan of the vi editor):

vi /etc/NetworkManager/system-connections/'Wired connection 1.nmconnection'  

[connection]
id=Wired connection 1
uuid=c0718bbc-fa2b-3be2-a863-4d946ffa16ff
type=ethernet
autoconnect-priority=-999
interface-name=enp5s0
timestamp=1740436074

[ethernet]

[ipv4]
dns=192.168.0.1;
dns-search=searchdomain.tld;
method=auto

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

[proxy]

Simply change the 'dns-search=searchdomain.tld;' accordingly and restart the NetworkManager:
systemctl restart NetworkManager

greetings
Frank face-smile