I kept getting timeout errors on 18.04 Bionic Beaver, until I switched to OpenDNS using these commands
sudo rm -f /etc/resolv.conf
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
sudo nano /etc/systemd/resolved.conf
# with body
nameserver 208.67.222.222
Should I really be doing this OpenDNS configuration with Netplan? I tried the following but it doesn't work.
# Create a netplan file
sudo vi /etc/netplan/50-cloud-init.yaml
.
# Put this in the body
nameservers:
addresses: [208.67.222.222, 208.67.220.220]
I also tried this syntax in the body to no avail, but maybe it because I'm on wifi and I called out 'ethernet'??? wlo1 is my wifi logical name when I sudo lshw -C network
.
network:
ethernet:
wlo1:
nameservers:
addresses: [208.67.222.222, 208.67.220.220]
You first have to make a decision to use NetworkManager or systemd-networkd. If you connect wi-fi to various wireless networks, then NetworkManager is probably the better choice. systemd-networkd is best used in servers, where the configuration doesn't change much. See https://netplan.io/examples.
/etc/netplan .yaml example to enable NetworkManager...
In
terminal
...sudo netplan generate
# generate config filessudo netplan apply
# apply the new configreboot
# reboot to confirm network operationAnother option is systemd-networkd.service, instead of NetworkManager.service.
Background story
I was having problems with NetworkManager when after changing network settings a couple of times the DNS would fail.
I noticed that
systemd-resolved.service
is supposed to work with bothnetwork-manager
andsystemd-network
.But
systemd-networkd
is actually part of thesystemd
family of software. So (I thought maybe) it will communicate better withsystemd-networkd
thanNetworkManager
. It tried it and it did seem better.How to set up
systemd-networkd
Set up
/etc/systemd/network/10-enp2s0.network
whereenp2s0
is the name of your interface as seen withifconfig
. It might beeth0
. Here is a simple example of DHCP with DNS override. Note theDNS=
directive can be used multiple times.The
[Network]
section for a fixed address.More examples
Test it out -
On my system with
systemd-resolved
running, theresolv.conf
file is a link -If the link is not replaced automatically during the
restart
, you might want to link it manually and restartsystemd-resolved
again.If its working as hoped than set their boot time startup behaviour -
Blame
There are always two sides to an interface.