Operating system: CentOS Linux release 7.8
Practical task: After configuring the resolv file, if you restart the CentOS operating system or restart the network service, the Ding Ding configuration in the resolv file will be lost. The steps to solve this problem are listed below.
[root@localhost network-scripts]# vi /etc/resolv.conf
# Generated by NetworkManager
nameserver 220.248.192.12
nameserver 220.248.192.13
nameserver 8.8.8.8
[root@localhost network-scripts]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 220.248.192.12
nameserver 220.248.192.13
nameserver 8.8.8.8
[root@localhost network-scripts]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=111 time=346 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=111 time=349 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=111 time=346 ms
[root@localhost network-scripts]# systemctl restart network
[root@localhost network-scripts]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 220.248.192.12
nameserver 220.248.192.13
[root@localhost network-scripts]# pwd
/etc/sysconfig/network-scripts
[root@localhost network-scripts]# vi ifcfg-eth0
......
DNS1=220.248.192.12
DNS2=220.248.192.13
DNS3 = 8.8.8.8
......
[root@localhost network-scripts]#systemctl restart network
[root@localhost ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 220.248.192.12
nameserver 220.248.192.13
nameserver 8.8.8.8