Starting in Ubuntu 18.04, data pipe prefs, including nameservers, are now controlled through theNetPlaninterface.
So, what prompted this change to using the new NetPlan interface?
Using a human-readable YAML file makes configuring complex networking configurations far easier to do.
In addition, debugging is quicker and errors are easier to track.
Instead of using/etc/resolv.conf, navigate to/etc/netplan, and you may find a series*.yamlfiles there.
NetPlan will load these files in the following directory order of precedence and then by the preceding number order.
NetPlan itself doesn’t monitor the active status, instead we use theipcommand to display this.
Within this configuration, you will find your active interfaces.
In this case, we are looking for theeth0configuration for purposes of this tutorial.
Included are the IPv6 resolvers as well.
If you want to use DHCP, you could replace the static IP configuration withdhcp4: yesunder theeth0section.
Additionally, if you use DHCP, you will need to set an override for nameservers.
Renderers
In some configurations, you might see arendererconfiguration listed.
There are two available types:NetworkManagerandnetworkd.
By default,networkdis used.
The difference is thatNetworkManageris the GUI manager used by Ubuntu, whereasnetworkdis used bySystemd.
It’s unnecessary to define this, as the default configuration should work in most cases.
If there is a failure, the configuration will automatically revert after 120 seconds.
you might open up a second shell to test out any configurations while this is applying.
This allows you to modify the configurations until it works.
To do so, initiate the netplanapplycommand like so.
If the interface is just switching nameservers, a reboot is generally unnecessary.
Bringing Interfaces Up and Down
Previously,ifconfigwas used to bring an interface up and down.
As noted previously though, theipcommand is taking the place ofifconfig.
In the example below,eth0is brought down and then back up.
Debugging NetPlan
What happens when a configuration goes wrong?
There are a few ways to explore the NetPlan configuration and figure out where a failure might have occurred.
One way to determine if the correct configuration was actively applied is to verify the configuration files generated in/run/systemd/connection.