CentOS7启用了新的dns管理工具
nmcli connection show 查看当前启动的连接
nmcli con mod eth0 ipv4.dns xxxxxxx 更改dns
此时测试无法解析域名
nmcli con up eth0 配置生效
再次尝试 可以解析域名了
[root@localhost yum.repos.d]# nmcli connection show名称 UUID 类型 设备 eth0 30ef1c27-a021-4c98-b0e6-f2bcecc3a05e 802-3-ethernet eth0 [root@localhost yum.repos.d]# nmcli con mod eth0 ipv4.dns "172.21.120.200 114.114.114.114"[root@localhost yum.repos.d]# nslookup baidu.com-bash: nslookup: 未找到命令[root@localhost yum.repos.d]# ping baidu.comping: baidu.com: 未知的名称或服务[root@localhost yum.repos.d]# nmcli con up eth0成功激活的连接(D-Bus 激活路径:/org/freedesktop/NetworkManager/ActiveConnection/2)[root@localhost yum.repos.d]# ping baidu.comPING baidu.com (180.149.132.47) 56(84) bytes of data.64 bytes from 180.149.132.47 (180.149.132.47): icmp_seq=1 ttl=52 time=204 ms64 bytes from 180.149.132.47 (180.149.132.47): icmp_seq=2 ttl=52 time=16.1 ms
另外也可以继续使用/etc/resolv.conf
[main]plugins=ifcfg-rhdns=none
重启网卡
systemctl restart NetworkManager.service
联系客服