
In this article, we will learn how to set the domain search on Ubuntu 18.04 without rebooting. This is a common task for system administrators and developers who need to configure their network settings.
Yes, it is possible to set the domain search on Ubuntu 18.04 without rebooting. You can use the Network Manager editing GUI, edit the Netplan configuration file, or use the nmcli
command-line tool to configure the domain search settings.
What is a Domain Search?
A domain search is a list of domains that the system will search when resolving a hostname. For instance, if you have a domain search set to example.com
, and you try to access a server named server1
, the system will automatically try to access server1.example.com
.
Setting Domain Search Using Network Manager Editor
The first method to set the domain search is by using the Network Manager editing GUI. This is a graphical interface that allows you to edit advanced network settings. Here’s how to do it:
- Open a terminal by pressing
Ctrl + Alt + T
. - Type
nm-connection-editor
and pressEnter
. This will open the Network Manager editing GUI. - Select the connection you want to edit and click on the
Edit
button. - In the
IPv4 Settings
tab, you will find theSearch domains
field where you can enter your domain search values. - After making the changes, click on the
Save
button.
Please note that you will need to disconnect and reconnect the network connection for the updates to apply.
Setting Domain Search Using Netplan Configuration
Ubuntu 18.04 uses Netplan for networking configuration. You can set the domain search by editing the Netplan configuration file. Here’s how to do it:
- Open a terminal.
- Type
sudo nano /etc/netplan/50-cloud-init.yaml
and pressEnter
. This will open the Netplan configuration file in a text editor. - Look for the
ethernets
section and add thesearch
field with your desired domain search values. It should look like this:
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
dhcp6: yes
search:
- example.com
- After saving the file, apply the changes by running
sudo netplan apply
.
Setting Domain Search Using nmcli Command-line Tool
You can also set the domain search through the command line using the nmcli
tool. Here’s how to do it:
- Open a terminal.
- Type
nmcli c show
and pressEnter
. This will list the available connections. - Modify the desired connection using the following command:
nmcli c modify "Connection Name" ipv4.dns-search "example.com"
Replace “Connection Name” with the name of your connection and “example.com” with your desired domain search.
- Finally, bring down and up the connection using the following command:
nmcli c down "Connection Name" && nmcli c up "Connection Name"
Conclusion
Setting the domain search on Ubuntu 18.04 without rebooting is a straightforward process. You can use the Network Manager editing GUI, edit the Netplan configuration file, or use the nmcli
command-line tool. Remember to disconnect and reconnect the network connection or restart the NetworkManager service for the changes to take effect.
The purpose of setting the domain search is to allow the system to automatically search for a domain when resolving a hostname, making it easier to access servers within the specified domain.
No, you do not need to reboot after setting the domain search. However, you will need to disconnect and reconnect the network connection or restart the NetworkManager service for the changes to take effect.
Yes, you can set multiple domain search values by separating them with a comma or adding them as separate items in a list, depending on the method you are using to set the domain search.
Setting the domain search should not affect other network settings. It is a specific configuration that determines the order in which the system searches for domains when resolving hostnames.
Yes, you can set the domain search for specific connections only. The methods mentioned in the article allow you to modify the domain search settings for individual connections.
You can verify if the domain search is set correctly by using the nmcli
command-line tool and running the command nmcli c show [connection name]
. It will display the connection details, including the domain search settings.
There is no specific limit to the number of domain search values you can set. However, it is recommended to keep the list concise and relevant to your network configuration for optimal performance.
Yes, you can set the domain search using DHCP. If your network uses DHCP to assign IP addresses, you can configure the DHCP server to include the domain search option in the DHCP lease, and the client will automatically receive and use the specified domain search values.
Changing the domain search should not affect existing connections. However, for the changes to take effect, you will need to disconnect and reconnect the network connection or restart the NetworkManager service.
Yes, you can set the domain search using a wildcard value. For example, you can set the domain search as *.example.com
, and the system will search for any subdomain under example.com
when resolving hostnames.