Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Configuring DNS (Domain Name System) on Ubuntu is an essential task for network administrators and users who need to manage their network settings efficiently. DNS is responsible for translating human-readable domain names into IP addresses, making it easier to access websites and services on the internet. Proper DNS configuration ensures faster and more reliable network connectivity.
In this article, we will guide you through the steps to configure DNS on Ubuntu. We will cover both the graphical interface method and the command-line method, providing practical examples and sample commands. This guide is applicable to various versions of Ubuntu, including Ubuntu 20.04 LTS and Ubuntu 22.04 LTS.
Examples:
Configuring DNS via Network Manager (Graphical Interface)
If you prefer using a graphical interface, you can configure DNS settings using the Network Manager.
Configuring DNS via Command Line
For users who prefer the command-line interface, DNS settings can be configured using the resolv.conf
file or the netplan
utility.
Using resolv.conf
:
Open a terminal.
Edit the /etc/resolv.conf
file using a text editor (e.g., nano
or vim
).
sudo nano /etc/resolv.conf
Add the desired DNS server addresses. For example:
nameserver 8.8.8.8
nameserver 8.8.4.4
Save the file and exit the text editor.
Using netplan
:
Open a terminal.
Edit the netplan configuration file located in /etc/netplan/
. The file name may vary, but it typically ends with .yaml
(e.g., 01-netcfg.yaml
).
sudo nano /etc/netplan/01-netcfg.yaml
Add the DNS server addresses under the nameservers
section. For example:
network:
version: 2
ethernets:
eth0:
dhcp4: yes
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
Save the file and exit the text editor.
Apply the changes using the netplan apply
command.
sudo netplan apply