How to set domain search on Ubuntu 18.04

Per my other answer focusing on 16.04 GNOME (which 18.04 basically has inherited), you can fix this by using the old-style Network Editor by running nm-connection-editor, which is the older Network Manager editing GUI we all love.

Basically, however, for 16.04 and onwards, the GNOME team for Ubuntu made some decisions about the older network editing menu, providing a trimmed down one for the average end user. Per Jeremy Bicha, from the #ubuntu-gnome IRC channel back in April:

jbicha: sorry it's hidden by default because most people don't need two network GUIs and the one in the Settings app should be easier to use for most people

The idea was basically that the 'most common options' that people would have to edit would be in the 'easier' settings GUI. But for more advanced users, they can still call nm-connection-editor to edit things like Search domains and such.

Note that the answer for 16.04 applies for 18.04. You can still use the other answer I wrote as a basis for solving this in 18.04.

(Note that you will need to disconnect and reconnect the network connection to get the search domain updates to apply, by the way. You do not need to restart all of the Network Manager services just to make this apply, just disconnect and reconnect your cable, and the updated profile configuration will apply)


It's possible to set it through CLI with :

nmcli c show
nmcli c modify "Wired connection 1" ipv4.dns-search "example.com"
nmcli c down "Wired connection 1" && nmcli c up "Wired connection 1"

We can check it by looking at /etc/resolv.conf and trying to resolve a hostname without the domain like so :

host www

Which will resolve the IP to www.example.com


Ubuntu 18.04 uses Netplan for networking.

$ vi /etc/netplan/50-cloud-init.yaml

ethernets:
        ens224:
            addresses: [192.168.86.30/24]
            dhcp4: no
            dhcp6: no
            gateway4: 192.168.86.1
            nameservers:
                    addresses: [192.168.86.10, 192.168.86.11]
                    search: [home.com, lab.com]
$ sudo netplan apply
$ cat /etc/resolv.conf

(the latter shows your search domains home.com and lab.com)