16

Since Ubuntu 18.04 , network GUI to setup network doesn't include any more the search domain field.

How can we set it again in a manner that resist to reboot?

samb
  • 1,306

4 Answers4

22

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)

Dan
  • 13,119
Thomas Ward
  • 74,764
  • 3
    Would be good if this answer made mention: restarting NetworkManager after using nm-connection-editor seems to be required for changes to take effect, e.g. sudo systemctl restart NetworkManager

    Until now I'd always just hand edited /etc/resolv.conf, but this old unix technique is apparently no longer allowed.

    In my case I just rebooted when I noticed changes weren't taking effect, which worked, but later found restarting NetworkManager is best; Reference: https://github.com/ansible/ansible/issues/17843

    – erco Jun 04 '19 at 23:16
  • @erco (also, all edit reviewers please read) Perhaps, but that's more of a note to be added at the end, and not a "How do I set this in the network editor" which was the original intent of the question/answer pair. – Thomas Ward Feb 12 '20 at 17:00
  • 1
    I guess I'm not supposed to say thanks, but thank you, because I never would have figured this out. And I guess I'm not support to start flamewars in comments, but words cannot express how incensed I am at how much time I've wasted on this, how drastically much harder it is under "modern" Linux to do what a quick 10-second edit of resolv.conf used to do. (And you've got to restart things before they take effect! Sheesh. What is this, W_____s? But nothing against you, Thomas -- thanks again.) – Steve Summit Jun 26 '20 at 17:46
  • The "decision by the GNOME team" added another layer of confusion on top of changing how network settings are managed, making it harder than ever to find and change network settings. Hiding the more complex features in the UI is one thing but removing them altogether was a stupid decision. We don't need two network GUIs, we just need one that works. Thanks, Thomas, for the explanation and for offering your solution. – Suncat2000 Sep 10 '23 at 18:16
14

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)

Zanna
  • 70,465
  • For Ubuntu Server 22.04, you also must add renderer: NetworkManager under network: in the netplan config for connections to show up as managed and be visible in the Gnome Desktop's connections GUI. The file I had to edit was /etc/netplan/00-installer-config.yaml. – Suncat2000 Sep 10 '23 at 18:25
4

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

samb
  • 1,306
1

But don't do as I did, and mistake it for an "additive" setup:

ethernets:
    ens224:
        nameservers:
            search: [home.com, lab.com]

$ sudo netplan apply

In an attempt to overwrite the "search" line in /etc/resolv.conf and expect that this is the only thing that will change. The above seems to remove alle the original settings from ens224 including whatever makes it work. So after the apply, the server was no longer reachable.

Yes, my own fault for not reading the manual. You have now been warned.

NoMann
  • 11
  • 2