-
Disable and stop the systemd-resolved service:
sudo systemctl disable systemd-resolved.service sudo systemctl stop systemd-resolved
-
Then put the following line in the
[main]
section of your/etc/NetworkManager/NetworkManager.conf
:dns=default
-
Delete the symlink
/etc/resolv.conf
rm /etc/resolv.conf
-
Restart network-manager
sudo service network-manager restart or sudo systemctl restart NetworkManager.service
-
-
Save zoilomora/f7d264cefbb589f3f1b1fc2cea2c844c to your computer and use it in GitHub Desktop.
Just a nit: I find it odd that you use service
to restart NetworkManager and not systemctl
since the former is just a compatibility wrapper around the latter.
this has started causing
sudo service network-manager restart
sudo: unable to resolve host ubuntu-18-04: Resource temporarily unavailable
Worked like a charm on Kubuntu 20.04.1 LTS.
Just a note in case people need to undo these instructions:
The symlink for /etc/resolv.conf points to ../run/systemd/resolve/stub-resolv.conf
/etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
This was helpful, I was trying to configure vhosts using network manager and the missing piece was deleting the symlink from systemd. Thanks!
I don't know why but ever since returning to the office (I'm on WIFI because someone let the cable fall behind the desk) I lose DNS resolution. It works for a few minutes then fails. This seems to have fixed it. Thanks!
dns=none
worked for me even after restarting the network-manager. However, dns=default
set the nameserver
to 127.0.0.53
after restarting it.
I got network-manager: unrecognized service
on ubuntu18.04, what should I do?
try to fix the chromium-based brower bug
[1116/153011.148474:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)
[1116/153011.148719:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)
@zhengxunWu1
sudo service network-manager restart
Did not work for me with Ubuntu 21.10
. I used the command from the source of this gist.
sudo systemctl restart NetworkManager
Thanks, this resolved VPN-issued DNS servers not being used in Docker containers for me on Pop_OS! 21.10.
If anyone wants to do it extra quick I wrote a little playbook:
# apt/yum install ansible, then:
curl -L https://bit.ly/3MqjHO0 > disable-systemd-resolved.yaml
ansible-galaxy collection install community.general
ansible-playbook -v disable-systemd-resolved.yaml
@thekoma: I'd advise everyone to no to use URL shorteners when it comes to blind code execution on user's machines. The content that hides behind that URL could change at any moment in time and could become malicious.
It's not blind. I'm not piping into bash. I've just shortened the gist url which is marked in the first statement.
But if you prefer: https://gist.githubusercontent.com/thekoma/b0d28f96b0384d9c630c244e216a6e03/raw/b9a2be01d6d0a7521c2102a7ea2c0bb74c0365c1/disable-systemd-resolved.yaml
We did not have NetworkManager service installed (fresh ubuntu 20.04). We kept the systemd-resolved service running and changed the /etc/resolv.conf
symlink to use another resolv.conf file.
Default symlink was this:
/etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
We changed it to:
/etc/resolv.conf -> ../run/systemd/resolve/resolv.conf
This means we don't use a 127.0.0.53 cached resolver, but we keep using the generated resolv.conf file from the systemd-resolved service. Which is overwritten/managed by netplan.
Original issue
We are running applications in docker which could not connect to any internally hosted applications on their local DNS name. Docker documentation about DNS:
By default, a container inherits the DNS settings of the host, as defined in the /etc/resolv.conf configuration file [..] If the container cannot reach any of the IP addresses you specify, Google’s public DNS server 8.8.8.8 is added, so that your container can resolve internet domains.
We discovered using journalctl -xeu docker
that docker was using google's DNS, so we figured that docker was not able to reach the configured DNS service. Which is correct. The /etc/resolv.conf file which was using nameserver 127.0.0.53
also for docker, resolves to the docker container and not the guest host.
Following these steps on a fresh Ubuntu 22.10 install completely breaks dns
Local dns servers are perfectly functional, Ubuntu sees them and they show in network config, but it refuses to use them, what gives?
Don't forget to add back the resolv.conf:
echo 'search example.com' > /etc/resolv.conf
echo 'nameserver 1.1.1.1' >> /etc/resolv.conf
echo 'nameserver 1.0.0.1' >> /etc/resolv.conf
systemd-resolvwhatever broke after upgrading ubuntu, and it was easier to just switch back to the Thing That Always Worked than to try to figure it out.
Following these steps on a fresh Ubuntu 22.10 install completely breaks dns
Local dns servers are perfectly functional, Ubuntu sees them and they show in network config, but it refuses to use them, what gives?
How do you solve the DNS issue for 22.10 please?
root@www::> systemctl disable systemd-resolved:> systemctl stop systemd-resolved
root@www:
root@www::> rm -f /etc/resolv.conf:> cat < /etc/resolv.conf
root@www:
nameserver 9.9.9.9
nameserver 8.8.8.8
nameserver 1.1.1.1
EOF
root@www:~:> reboot
Why not just rename instead of remove?
mv /etc/resolv.conf /etc/resolv.conf.del
@euntae: With just stopping instead of also disabling systemd-resolved it will be active again after a reboot but the way you described it the entries in resolv.conf won't get used anyway at least on Ubuntu 24.
I was going crazy with this on the steam deck. NetworkManager kept creating a resolv.conf always pointing to 127.0.0.53.
Until I found that SteamOS (arch in disguise) had created a /etc/NetworkManager/conf.d/dns with a
[main]
dns=systemd-resolved
And that was being used instead of my conf file with dns=default
...
This just saved my butt. For some reason resolved just decided to stop working. After two hours of pain killing resolved did the trick. Yet one more reason why I hate systemd. Just want it do die a painful death.