我运行的是 CentOS 7.9,为什么/etc/resolv.conf
重启后我的就变了?
重新启动之前:
# cat /etc/resolv.conf
search myDomain.lan
nameserver x.y.z.t1
nameserver x.y.z.t2
重启后:
# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver a.b.c.d
被NetworkManager.service
屏蔽并且没有运行:
# systemctl status NetworkManager.service
● NetworkManager.service
Loaded: masked (/dev/null; bad)
Active: inactive (dead)
EDIT0:systemd-resolved
此处未安装:
# systemctl status systemd-resolved
Unit systemd-resolved.service could not be found.
找到它:该脚本定义了要在变量中启动的/etc/rc.d/init.d/network
接口:ifup
interfaces
$ grep __sed_discard_ignored_files= /etc/init.d/functions
__sed_discard_ignored_files='/\(~\|\.bak\|\.old\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d'
$ cd /etc/sysconfig/network-scripts
$ interfaces=$(ls ifcfg-* | \
LC_ALL=C sed -e "$__sed_discard_ignored_files" \
-e '/\(ifcfg-lo$\|:\|ifcfg-.*-range\)/d' \
-e '{ s/^ifcfg-//g;s/[0-9]/ &/}' | \
LC_ALL=C sort -k 1,1 -k 2n | \
LC_ALL=C sed 's/ //')
$ echo $interfaces
bond0 bond0.ORIG em1 em2 em3 em4
$ sdiff -s /etc/sysconfig/network-scripts/ifcfg-bond0 /etc/sysconfig/network-scripts/ifcfg-bond0.ORIG
DNS1=x.y.z.t1 | DNS1=a.b.c.d
文件bond0.ORIG
是罪魁祸首。