How to modify and activate the DNS settings in Ubuntu?
There are several methods to choose from to modify and activate DNS on Ubuntu.
Option 1: Set up using network management tools.
- Open the “Settings” application.
- Select “Network” from the sidebar.
- Choose your network connection in the right-hand pane.
- Click on the “Options” button.
- Switch “Automatic” to “Manual” in the “IPv4” or “IPv6” tab.
- Enter the IP address of the new DNS servers you want to use in the “DNS” field. Separate multiple DNS servers by using commas.
- Click on “Apply” to save the changes.
Option 2: Setting up through the terminal.
- Open the terminal.
- Edit the “/etc/resolv.conf” file.
Use the command “sudo nano /etc/resolv.conf” - Add the following line at the top of the document (replace [DNS IP] with the IP address of the new DNS server you want to use):
nameserver [DNS IP] - Press Ctrl + X to save and close the file.
Option 1: Implementing settings using the NetworkManager command line tool.
- Open the terminal.
- To view available network connections, use the following command: nmcli connection show
- Edit the DNS settings of the connection you wish to modify using the following command: nmcli connection modify connection_name ipv4.dns [DNS IP], replacing “connection_name” with the name of the connection you want to edit.
- Use the following command to apply the changes:
nmcli connection up connection_name
Please be aware that if you are using NetworkManager for network management, you should avoid directly editing the “/etc/resolv.conf” file because NetworkManager will automatically update it and may overwrite your changes.
After changing the DNS, you may need to restart your network connection or computer for the changes to take effect, regardless of the method you choose.