Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Configure DNS on Ubuntu: A Comprehensive Guide

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:


1. Configuring DNS via Network Manager (Graphical Interface)


If you prefer using a graphical interface, you can configure DNS settings using the Network Manager.



  • Open the "Settings" application from the application menu.

  • Navigate to the "Network" section.

  • Select the network connection you want to configure (e.g., Wired or Wi-Fi).

  • Click on the "Settings" icon next to the network connection.

  • Go to the "IPv4" or "IPv6" tab, depending on your network configuration.

  • In the "DNS" section, select "Automatic (DHCP)" or "Manual" based on your preference.

  • If you choose "Manual," enter the DNS servers you want to use (e.g., 8.8.8.8 for Google DNS).

  • Click "Apply" to save the changes.


2. 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



To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.