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.
Setting up a DNS domain name resolution server in Ubuntu desktop version is very simple and does not require any technical knowledge.
Open the settings window
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.
Select the network connection you want to set up DNS, and click the gear-shaped button to open the network manager.
Select the IPv4 settings tab.
Disable the automatic switch, and enter the DNS IP addresses, separated by commas. We use Google DNS domain name resolution server.
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.
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
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