Solve the problem of resolv.conf reset after Linux restart

Solve the problem of reset Linuxafter restartresolv.conf

Arch WikiSolution:

① In /etc/NetworkManager/conf.d/the folder, create a new dns.conffile and dns.conffill 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 PortalSolution:

① 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 NetworkManageris 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 DNSprocessing, NetworkManagermanually configured settings are not overwritten.

Recommended solution:

Use the following command to resolv.confmake the file read-only, then the file NetworkManagercannot be modified resolv.conf:

$ sudo chattr +i /etc/resolv.conf

hint:

Can be sudo chattr +i /etc/resolv.confadded to any previous position /etc/rc.localinside .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.

Guess you like

Origin blog.csdn.net/GaaraZ/article/details/127424652