16

I've decided systemd-resolved is irretrievably broken garbage and I'd like to replace. I've got my own local DNS server at 192.168.1.2 I'd like. I'd also like to connect to a VPN with NetExtender that gives me a DNS server for a .local domain. I would like these two things to work together, what can I do?

3

3 Answers 3

6

The answer by Gannet is incorrect. If you want to use plain ifupdown like in earlier releases, without netplan or NetworkManager (e.g. on a server), with dhcp, you need to do this:

systemctl disable systemd-resolved.service
systemctl stop systemd-resolved.service

# check if resolv.conf is pointing to resolvconf
ls -la /etc/resolv.conf
# lrwxrwxrwx 1 root root 27 May  7 16:15 /etc/resolv.conf -> /run/resolvconf/resolv.conf
# if not, delete /etc/resolv.conf and symlink it like this: 
rm /etc/resolv.conf
ln -s /run/resolvconf/resolv.conf /etc/resolv.conf

# this will remove the resolved stub resolver entry from resolv.conf
resolvconf -d systemd-resolved

# fix dhclient scripts
chmod -x /etc/dhcp/dhclient-enter-hooks.d/resolved
chmod +x /etc/dhcp/dhclient-enter-hooks.d/resolvconf

# on my machine just chmod -x wasn't enough, I had to move the resolved script somewhere else
mv /etc/dhcp/dhclient-enter-hooks.d/resolved ~

# ifdown/ifup your interface to regenerate resolv.conf (or systemctl restart ifup@eth0)
ifdown eth0; ifup eth0

# check /etc/resolv.conf has the right settings

1
  • You, sir, are one of those unknown heroes that save the day.
    – ata
    Commented Jun 8, 2021 at 2:17
3

You can always disable your systemd-resolved by

systemctl disable systemd-resolved.service

command. And run:

sudo rm /etc/resolv.conf && sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

to use /etc/resolv.conf config as it was earlier in previous ubuntu versions.

1
  • can it be removed via apt ? Commented Jan 10, 2020 at 9:20
-1

Both answers can lead to issues with VPN. Also, if it's desired to keep NetworkManager, the following can be done:

Unlink resolvconf if this is linked to resolvectl:

ls -lah $(which resolvconf)

If resolveconf is linked to resolvectl, like the following:

/usr/local/bin/resolvconf -> /usr/bin/resolvectl

We need to unlink it:

sudo unlink /usr/local/bin/resolvconf

Now, install resolvconf because most VPN uses it:

sudo apt-get install resolvconf

set dns=none to [main] section in /etc/NetworkManager/NetworkManager.conf:

[main]
...
dns=none

Now, we have two options here:

  • Manually set DNSes system-wide
  • Use resolvconf to set DNS:

Manually set DNSes system-wide

Place desired DNS servers as nameserver in /etc/resolv.conf:

nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 1.1.1.1

Use resolvconf to set DNS

This is preferred way if you're using a VPN with specific DNS servers configured through it

sudo ln -sfn /run/resolvconf/resolv.conf /etc/resolv.conf
3
  • I followed your guide and now I have no internet. Any help would be appreciated. Thanks!
    – Alex
    Commented Nov 2, 2022 at 1:49
  • I made a new post about this. Feel free to comment there. Thanks askubuntu.com/questions/1438645/…
    – Alex
    Commented Nov 2, 2022 at 2:01
  • @Alex could you please post modified files content? - ls -lah $(which resolvconf) - /etc/NetworkManager/NetworkManager.conf - /etc/resolv.conf
    – meetnick
    Commented Jan 11, 2023 at 15:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .