How to set DNS nameserver in Ubuntu Server 18.04
For years, whenever you need to configure a DNS nameserver in Linux, users will find /etc/resolv.conf. Some simple settings will help your computer reach out to the outside world:
nameserver 8.8.4.4
nameserver 8.8.8.8
But, like everything else, technology is always growing. Developers are always trying to change the way people manage things for decades. This is true for open source technology.
That is the case of DNS on Ubuntu Server. Although the /etc/resolv.conf file still exists, it is no longer the place you configure your DNS nameserver. Network changes continue to be made public. But, to be fair, the DNS configuration is actually incomplete (at least not permanently) in resolv.conf files for quite some time. In fact, before Ubuntu 18.04, the DNS nameserver has been configured in / etc / network / interfaces. In this file, the following item will help you get out of your LAN:
dns-addresses 8.8.4.4.8.8.8.8
Log in to server 18.04 and find the file / etc / network / interfaces . However, you can configure all you want, but they won't work. Why? That's because Netplan, a new networking block for Ubuntu. Now, users can configure DNS nameserver via Netplan.
Why does Canonical make this change? According to official documents, the reason is: Netplan has been deployed to simplify complex network configurations, as well as solve some of the current limitations of ifupdown. Netplan provides a simple and beautiful yaml configuration format with support for many backend providers.
In other words, everything has been simplified (especially when considering the popularity of the .yaml format).
New configuration
Although many people don't like to change, switching to Netplan is definitely the right step. With this change, the user's network configuration is handled in a single location (each interface has its own configuration file). Configuration files are found in / etc / netplan. The file name will be in the form 01-netcfg.yaml. One of the most important aspects of this file is to be aligned consistently (otherwise they will not load). In these files, the user will configure all aspects of the network interface (including IP addresses, ports, DNS, etc.). For DNS configuration, this is done with two lines of code. For example, if you use Google's DNS server, enter the command like in the image below.
DNS servers are separated by commas. To keep things neat, you should combine the related servers together as shown in the image below.
Of course, you can also set all DNS server addresses on one line.
As long as they are separated by commas or even add spaces after each comma.
Now, everything is more neat and readable. Once you've made the configuration changes, save and close the file, then enter the following command:
sudo netplan apply
The configuration will be read and will be valid, as long as it is in the appropriate format. If something goes wrong, you can add the debug switch as follows:
sudo netplan --debug apply
The above command will provide all the necessary output to troubleshoot the network configuration.
Whether you like it or not, this is currently the Ubuntu network configured. Make sure you are catching up with new changes in the Ubuntu world, otherwise you will be increasingly frustrated about why your network is constantly experiencing problems. Netplan is here to make things easier.
Good luck!
See more:
- How to configure DNS Server on Ubuntu Server 11.04
- Instructions for installing Ubuntu Web Server on remote host
- Instructions for installing BIKA LIMS Inkosi on Ubuntu Server
You should read it
- How to install FTP Server on Ubuntu
- How to Install Ubuntu Server
- What's New in Ubuntu 21.10?
- How to Set Up an FTP Server on Ubuntu Linux
- How to install desktop/GUI environment in Ubuntu Server
- Why is Ubuntu LTS preferred over regular distros?
- How to configure DNS Server on Ubuntu Server 11.04
- What's new in Ubuntu 18.04 LTS just released?
May be interested
- 5 best Markdown editors for Linuxpreviously, tipsmake.com has introduced 6 best free online markdown editors and converters and now the best markdown editors for linux.
- How to use DNS over TLS on Ubuntu Linuxyou can use dns in which all dns queries are processed through the encrypted tls (transport layer secure) protocol. however, most operating systems do not work with dns over tls.
- How to fix broken packages in Ubuntuapt, ubuntu's package manager, is one of the most powerful and intuitive tools, but that doesn't mean that this manager never happens to be a problem.
- 11 great LXDE themes for Linuxthe default theme that comes with lxde desktop environment is outdated and extremely bland. but don't worry! because this desktop environment is on linux, users can freely change their preferences.
- How to take a screenshot of the login screen in Linuxthere are many screen capture utilities available for linux and most work very well. but strangely, none of these tools have the ability to take a screenshot of the login screen.
- Instructions for using zforce command on Linuxthe gzip command is a popular tool used to compress / decompress files in linux. tipsmake.com presents the basics of this tool in the article: some basic terminal commands in linux mint 11.