How do I set DNS servers in Linux?
To set DNS servers in Linux, you can edit the /etc/resolv.conf
file directly by adding lines like:
However, if you’re using NetworkManager, it’s better to configure DNS servers using nmcli
:
Alternatively, if you’re using systemd-resolved, you can edit /etc/systemd/resolved.conf
to specify DNS servers and then restart the service.