How to set up a DNS server on Ubuntu 18.04

Domain Name Resolution The system (DNS) is a central part of the Internet architecture, which provides a way to resolve domain names to IP addresses. You can think of DNS as the phone book of the Internet.

Each device connected to the Internet is identified by an independent IP address. When you enter the URL of the website you want to browse in the browser, its domain name must be resolved to its corresponding IP address. The operating system first detects the local hosts file. If there is no related entry for the domain name, it will query the specified domain name through the DNS domain name resolution server.

Once the domain name is queried for the IP address, the system will cache the request and save a record locally about the domain name and the corresponding IP.

DNS domain name resolution servers are servers that are specially used by other devices to perform DNS queries on requested domain names.

Usually, the DNS resolution server is provided by your ISP provider. In any case, these domain name resolution servers may be slow or not updated normally, which sometimes leads to the wrong IP address, so that you cannot resolve the domain name you want.

There are also some free, public DNS domain name resolution servers, which are fast, private and can be updated normally.

The following is a well-known public DNS resolution server:

In this guide, we will explain how to configure DNS name resolution server on Ubuntu 18.04.

1. Set up DNS domain name resolution server in Ubuntu desktop version##

Setting up a DNS domain name resolution server in Ubuntu desktop version is very simple and does not require any technical knowledge.

  1. Open the settings window

  2. If you are connected to a WiFi network, click on the "Wi-FI" tab. Otherwise, if you have a wired connection, click on the "Network" tab.

  3. Select the network connection you want to set up DNS, and click the gear-shaped button to open the network manager.

  4. Select the IPv4 settings tab.

  5. Disable the automatic switch, and enter the DNS IP addresses, separated by commas. We use Google DNS domain name resolution server.

  1. Click the "Apply" button to save the changes.

This modification should be effective immediately, unless those DNS entries are already cached.

If you want to switch back to the old settings, open the network manager, IPv4 settings, and enable the automatic switch.

2. Set up DNS domain name resolution server in Ubuntu server version##

In the past days, no matter which Linux you want to set up a DNS resolution server, you would simply open /etc/resolv.conf, edit the entries, save, and you're done. This file still exists, but is taken over by the systemd server and cannot be edited manually.

systemd-resolved is a server that provides a local DNS domain name solution and can be configured through Netplan. Netplan is the default network management tool on Ubuntu 18.04.

The Netplan configuration file is in the /etc/netplan directory. You will find one or two YAML files in this directory. This file is different from the step-by-step operation. Usually, the files are named 01-netcfg.yaml and 50-cloud-init.yaml, but it may be different in your system.

These files allow you to configure network interfaces, including IP addresses, gateways, DNS domain name resolution servers, and so on.

To configure the DNS domain name resolution server, use your text editor to open the network interface configuration file:

sudo nano /etc/netplan/01-netcfg.yaml

The content of this file looks like this:

network:
 version:2
 renderer: networkd
 ethernets:
 ens3:
  dhcp4: no
  addresses:-192.168.121.199/24
  gateway4:192.168.121.1
  nameservers:
   addresses:[8.8.8.8,8.8.4.4]

Configure the DNS domain name resolution server of the interface, and modify the current IP address to your favorite DNS server. For example, if you want to use Cloudflare's DNS domain name resolution server, you can modify the address line to:

 nameservers:
   addresses:[1.1.1.1,1.0.0.1]

DNS domain name resolution servers must be separated by commas. You can also add two or more domain name resolution servers.

If this entry does not exist, add it to the interface name configuration block. When editing this Yaml file, please make sure you meet the YAML code indentation standard. If there is a syntax error, Netplan will not be able to parse the file.

Once the settings are complete, save the file and apply the changes:

sudo netplan apply

Netplan will generate configuration files for the systemd-resolved service.

To verify that the new DNS domain name resolution server is set up correctly, run the following command:

systemd-resolve --status | grep 'DNS Servers'-A2

systemd-resolve -status prints out a lot of information. We use grep to consider the "DNS Servers" field. The output will look like this:

  DNS Servers:1.1.1.11.0.0.1

Three, summary##

Netplan is the default network management tool on Ubuntu 18.04, replacing the /etc/resolv.conf and /etc/network/interfaces configuration files used to configure the network on previous Ubuntu versions.

Recommended Posts

How to set up a DNS server on Ubuntu 18.04
How to set up Shiny Server on Ubuntu 14.04
How to set up Gogs on Ubuntu 14.04
How to set up R on Ubuntu 14.04
How to set up a Masterless Puppet environment on Ubuntu 14.04
How to set up a firewall with UFW on Ubuntu 14.04
How to set up a production Elasticsearch cluster on Ubuntu 14.04
How to set static IP on Ubuntu 18.04 Server
How to set static IP on Ubuntu 18.04 Server
How to set up time synchronization on Ubuntu 18.04
How to set a fixed IP based on Ubuntu 16.04
How to set up Java Home on Ubuntu and Raspbian
Teach you how to build a Git server on Ubuntu
How to set up vsftpd for anonymous downloads on Ubuntu 16.04
How to set up an Apache virtual host on Ubuntu 16.04
How to set up an Apache virtual host on Ubuntu 20.04
How to set up password authentication with Nginx on Ubuntu 14.04
How to set up vsftpd for user directories on Ubuntu 16.04
Detailed steps to set up a Git server on CentOS
How to install Bacula Server on Ubuntu 14.04
How to use Samba server on Ubuntu 16.04
How to set PostgreSQL startup on Ubuntu 16.04
How to install Zabbix on Ubuntu 16.04 Server
How to set up the Nginx server configuration block on CentOS 8
How to install Squid proxy server on Ubuntu 18.04
How to set up SSH keys on CentOS 8
Explain how to set static IP on ubuntu14.04
How to quickly deploy docker on ubuntu server
How to run the parsing server on Ubuntu 14.04
How to set up Ghost one-click app for Ubuntu 16.04
How to start a blog with Hexo on Ubuntu 14.04
How to configure a fixed IP based on Ubuntu 18.04
How to open https on nginx server under Ubuntu
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Nginx on Ubuntu 20.04
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to install Anaconda3 on Ubuntu 18.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install PrestaShop on Ubuntu 16.04
How to upgrade to PHP 7 on Ubuntu 14.04
How to install Skype on Ubuntu 20.04
How to install Jenkins on Ubuntu 20.04
How to install Python 3.8 on Ubuntu 18.04
How to install KVM on Ubuntu 18.04