Changing your Ubuntu name server involves modifying the network configuration to point your system to a different DNS server. Here's how you can do it:
1. Editing the /etc/resolv.conf
File
This file contains the DNS server settings for your system. You can edit it directly using a text editor like nano
or vim
.
sudo nano /etc/resolv.conf
Replace the existing DNS server addresses with your desired ones. For example, to use Google Public DNS, you would add the following lines:
nameserver 8.8.8.8
nameserver 8.8.4.4
Save the file and exit the editor.
2. Using the nmcli
Command
The nmcli
command provides a convenient way to manage network connections. You can use it to modify the DNS settings for your active connection.
sudo nmcli connection modify <connection_name> ipv4.dns <dns_server_1> <dns_server_2>
Replace <connection_name>
with the name of your active network connection (e.g., eth0
, wlan0
) and <dns_server_1>
and <dns_server_2>
with the desired DNS server addresses.
3. Modifying Network Manager Settings
If you're using Network Manager, you can change the DNS settings through its graphical interface. Open the Network Manager applet, click on your active network connection, select "Edit Connections," and then modify the DNS settings under the "IPv4 Settings" tab.
4. Configuring Network Interfaces
For more advanced configurations, you can modify the network interface files located in /etc/network/interfaces.d/
. These files allow you to define specific DNS settings for individual network interfaces.
5. Verifying the Changes
After making any changes, you can verify them by running the nslookup
command. For example:
nslookup google.com
This will show you the DNS server used to resolve the hostname.
By following these steps, you can easily change the name server used by your Ubuntu system. Choose the method that best suits your needs and preferences.