Solve the problem of reset Linux
after restartresolv.conf
Arch Wiki
Solution:
① In /etc/NetworkManager/conf.d/
the folder, create a new dns.conf
file and dns.conf
fill in the following content in the file:
[main]
dns=none
main.systemd-resolved=false
② Use the following command to reload NetworkManager
the service:
# systemctl reload NetworkManager
Red Hat Customer Portal
Solution:
① As the root user, use a text editor to create /etc/NetworkManager/conf.d/90-dns-none.conf
a file containing the following content:
[main]
dns=none
main.systemd-resolved=false
② Edit /etc/resolv.conf
the file and update the configuration manually.
③ Reload NetworkManager
service:
# systemctl reload NetworkManager
Notice:
After reloading the service, the file
NetworkManager
is no longer updated/etc/resolv.conf
.But the last contents of the file will be preserved.
④ Display /etc/resolv.conf
files:
# cat /etc/resolv.conf
If you successfully disable DNS
processing, NetworkManager
manually configured settings are not overwritten.
Recommended solution:
Use the following command to resolv.conf
make the file read-only, then the file NetworkManager
cannot be modified resolv.conf
:
$ sudo chattr +i /etc/resolv.conf
hint:
Can be
sudo chattr +i /etc/resolv.conf
added to any previous position/etc/rc.local
inside .exit 0
Notice:
After performing the three steps in sequence, it has indeed not been modified again.
If you don't want to do it one by one, you can just use the third step.