I know some ways to change the address of nameservers in DNS.
One is using resolvconf
:
$ sudo apt install resolvconf
$ sudo systemctl start resolvconf.service
Then add some lines to the file/etc/resolvconf/resolv.conf.d/head
And then restart the service:
$ sudo systemctl restart resolvconf.service
$ sudo systemctl restart systemd-resolved.service
Problem : The problem with this approach is that the file head
, where the DNS address is added, indicates that it should not be edited.
The other is installing dnsmasq
:
$ sudo apt-get install dnsmasq
Editing the file /etc/dnsmasq.conf
:
...
server=8.8.8.8
server=8.8.4.4
...
And restarting the services:
$ sudo service dnsmasq restart
$ sudo service network-manager restart
Problem : When I run cat /etc/resolv.conf
, I can't find the addresses I added. Also, when I do a dig google.com
, in the part of SERVER
, I get the value of 127.0.0.1
, and not the addresses I added, but not the original ones either.
On the other hand, I know that I can't edit the file /etc/resolv.conf
, since it is overwritten by other services.
I would like to know if there is a "cleaner" way to change DNS addresses.
"Clean", in the sense of seeing the results of the reflected DNS server path, but without having to edit files in which it is indicated that editing is not recommended.
I was asking friends and networking forums, and in the end I got an answer related to systemd .
The specifications of my equipment are:
Create this virtual machine using the google cloud console.
In my case, the VM is using the weird framework
systemd
(which has always caused me a lot of conflicts), and what I did was the following:Edit the /etc/systemd/resolved.conf file
Replace file
/etc/resolv.conf
:restart the service
sudo service systemd-resolved restart
And ready. When I run,
systemd-resolve --status
, I get:And when I do a
dig
, I get:In this way I managed to modify the DNS without installing any new program. Perhaps if I forced the issue a bit by abruptly modifying the
/etc/resolv.conf
.