I want to configure DNS, modify/etc/resolv. conf, restart service network restart after modification, and modify/etc/resolv. conf. The information is lost. Please take a look.
Configuration before modification
# No nameservers found; try putting DNS servers into your
# Ifcfg files in/etc/sysconfig/network-Scripts like so:
#
# Dns1 = XXX. XXX
# Dns2 = XXX. XXX
# Domain = lab.foo.com bar.foo.com
Solution: Add dns1 = XXX. XXX directly in the ifcfg-eth0, and then Service Network restart
Device = "eth0 ″
Bootproto = "static"
Hwaddr = "00: 0C: 29: B5: e4: 65 ″
Nm_controlled = "yes"
Onboot = "yes"
Ipaddr = 192.168.128.20.
Netmask = 255.255.255.0
Gateway = 192.168.128.1
Dns1 = 222.46.120.6
Check that resolv. conf has one more namerserver XXX. XX.
# Generated by NetworkManager
Nameserver 222.46.120.6
Method 2:
Finally found an article to solve my problem: http://tech.techweb.com.cn/archiver/tid-380658.html
Article content:
Vim/etc/resolvconf/resolv. conf. d/head File
Display the same content as resolv. conf:
# Dynamic resolv. conf (5) file for glibc resolver (3) generated by resolvconf (8)
# Do not edit this file by hand-your changes will be overwritten)
Enter nameserver 202.102.152.3
Save and exit,
Resolvconf-u
In this case, you can access the Internet normally. After restarting, you do not need to reset the DNS.
[Switch] resolv. conf configuration information lost after restart Solution