I upgraded from Ubuntu 20.04 to 22.04.1 yesterday.
Now, whenever I toggle wifi back on (from temporarily being off), I have no internet access.
I checked:
ls -lah /etc/resolv.conf
lrwxrwxrwx 1 root root 28 Feb 7 14:24 /etc/resolv.conf -> /opt/valet-linux/resolv.conf
cat /etc/resolv.conf
search attlocal.net
nameserver 127.0.0.1
Then I makes changes:
sudo vim /opt/valet-linux/resolv.conf
cat /opt/valet-linux/resolv.conf
nameserver 8.8.8.8
And then the internet works again.
But if I toggle Wi-Fi off and then back on, that file gets reset again.
I've already tried:
and:
cat /etc/netplan/01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
eth0:
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
from https://linuxize.com/post/how-to-set-dns-nameservers-on-ubuntu-18-04/ and countless posts on AskUbuntu and StackOverflow.
I've also tried:
cat /etc/dhcp/dhclient.conf
...
# https://stackoverflow.com/a/48652642/470749
supersede domain-name-servers 8.8.8.8;
from https://stackoverflow.com/a/48652642/470749.
Nothing works. I'm losing my patience with Ubuntu.
What have I done to get myself in this mess? Thanks.
There can be only one entry that writes/managed
/etc/resolv.conf
.For example,
NetworkManager
or the human administrator. There is alsoresolvconf
, which is a tool that accepts multiple sources for DNS configuration, and then merges them into one/etc/resolv.conf
.By default, NetworkManager runs with
[main].rc-manager=symlink
setting. Seeman NetworkManager.conf
. Unless you changed that configuration, NetworkManager won't touch the file. Read also about[main].dns=
setting.In general, you need to make up your mind about what should configure it, and then configure all related software to agree on that. Since NetworkManager by default already leaves the file alone, if it's a symlink, you don't need to tell NetworkManager to stay off.
If you use one of the GUIs to configure DNS, then those GUIs actually configure the profile in NetworkManager. That only works, if NetworkManager is instructed to write
/etc/resolv.conf
Commonly
systemd-resolved
is used. Resolved doesn't write/etc/resolv.conf
, but it can consume it as input. If you use that, usually/etc/resolv.conf
should be just a symlink as documented in/ETC/RESOLV.CONF
section inman systemd-resolved
. In that case, NetworkManager can push it's DNS configuration tosystemd-resolved
. Runresolvectl
to see that configuration insystemd-resolved
.Changing
/etc/dhcp/dhclient.conf
seems quite wrong. Especially, if you use NetworkManager which by default doesn't use dhclient. In any case, injecting the DNS setting in the DHCP client is not right. In NetworkManager, you configure DNS by setting it in NetworkManager's connection profiles (+ setup your system and NetworkManager to do the right thing with those settings).There is not one answer, because it depends on how exactly you want to set up your system. Commonly you would stick to what your distro provides you with. Understand what your distro is setup to do, and use the appropriate mechanisms in that case. Who created
/etc/resolv.conf
as a symlink, and why did it do that? (Neither NetworkManager nor systemd-resolved would do that).Since I hadn't used valet-linux for years, I'd completely forgotten about it and didn't even recognize the name.
Thanks to @chili555 for the comment pointing out what I didn't even notice as unusual.
I finally found https://github.com/cpriego/valet-linux/issues/115#issuecomment-1406379951, which in combination with commands like the following (inspired by https://cpriego.github.io/valet-linux/#uninstalling), seemed to work:
Use
systemd-resolve
instead of manually editingresolve.conf
.for example: