With the latest iteration of Ubuntu comes much change. Jack Wallen shows you how DNS nameserver entries are now configured for networking interfaces in Ubuntu Server 18.04.
For years, whenever I needed to configure DNS nameservers in Linux I would turn to /etc/resolv.conf. A couple of quick entries like so would have my machine reaching the outside world like a champ:
nameserver 184.108.40.206 nameserver 220.127.116.11
But, as with everything, technology evolves. This is especially true with the things you know the most. It never fails that developers will throw a wrench into your works to change the way you've been doing your admin thing for decades. This is true for both open and closed source technologies.
Such is the case with DNS on Ubuntu Server. Although the /etc/resolv.conf file still exists, it is no longer where you configure your DNS nameservers. That's right, the networking changes keep on coming. But then, to be fair, configuring DNS hasn't actually been configured (at least not permanently) in the resolv.conf file for quite some time. In fact, prior to Ubuntu 18.04, DNS nameservers were configured in /etc/network/interfaces. In this file, an entry as you see below would successfully get you beyond your LAN:
Log into your 18.04 server and look for that /etc/network/interfaces file. Guess what? It's there. However, you can configure it all you want, but it'll have zero effect. Why? Netplan. That's the new kid on the Ubuntu networking block. It is through Netplan that we now configure our DNS nameservers.
Why did Canonical make this move? From the official documentation, comes this:
Netplan has been implemented to support simple, declarative representation of complex network configurations, as well as address some current limitations of ifupdown. Netplan provides a simple and elegant yaml configuration format with support for multiple backend providers.
In other words, simplicity. And it does make sense (especially considering how popular the .yaml format is becoming).
SEE: 20 quick tips to make Linux networking easier (free PDF) (TechRepublic)
The new configuration
Although many do not like change, I believe Netplan was the right move. With this change, your network configurations are handled in one location (each interface having their own configuration file). The configuration files are found in /etc/netplan. The file names will be in the form 01-netcfg.yaml. One of the most important aspects of the file is that they must use a consistent indent (otherwise they will fail to be loaded). Within these files, you configure all aspects of a network interface (IP address, gateway, DNS, etc). As for the DNS configuration, this is done with two lines of code. For example, if you use Google's DNS servers, the entry would look like that shown in Figure A.
DNS servers are comma separated. To keep things clean, I recommend combining related servers together as you see in Figure B.
You can, of course, fit all of those DNS server addresses on a single line (Figure C).
As long as they are comma-separated, everything will be groovy. You can even separate them more clearly, by adding a space after the comma (Figure D).
Once you've made the configuration change, save/close the file, and then issue the command:
sudo netplan apply
The configuration will be read and, so long as it is in the proper form, will take effect. If something goes askew, you can add the debug switch like so:
sudo netplan --debug apply
The above command will give you all the output you need to troubleshoot your network configuration (Figure E).
Welcome to the new world order
Whether you like it or not, this is how Ubuntu networking is now configured. Make sure you're up to speed on the new Ubuntu world order, otherwise you'll wind up growing exponentially frustrated as to why your networking continues to fail. Netplan is here to stay.
- How to install nextCloud 13 on Ubuntu 18.04 (TechRepublic)
- How to change the hostname on Ubuntu 18.04 (TechRepublic)
- How to configure a static IP address in Ubuntu Server 18.04 (TechRepublic)
- How to install Ubuntu Server 18.04 (TechRepublic)
- Mark Shuttleworth dishes on where Canonical and Ubuntu Linux are going next (ZDNet)