RHEL7.3 DNS配置

   在RHEL7下,手工设置 /etc/resolv.conf 里的DNS有可能被系统清除或覆盖,与7.0以前的配置不同,可以使用一下几种方式配置。
   1、使用全新的命令行工具 nmcli 来设置
   查看网卡信息:
[root@ocsserver ~]# nmcli connection show
名称   UUID                                  类型            设备  
ens32  4ede51c5-54c1-4503-8d4b-314119134088  802-3-ethernet  ens32 
   修改当前网络连接对应的DNS服务器,这里的网络连接可以用名称或者UUID来标识
[root@ocsserver ~]# nmcli con mod ens32 ipv4.dns "8.8.8.8"   
   将dns配置生效

[root@ocsserver ~]# nmcli con up ens32
成功激活的连接(D-Bus 激活路径:/org/freedesktop/NetworkManager/ActiveConnection/1
   查看dns配置信息:
[root@ocsserver ~]# cat  /etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8
   2、手工修改 /etc/resolv.conf
   修改 /etc/NetworkManager/NetworkManager.conf 文件,在main部分添加 “dns=none” 选项:
[root@ocsserver ~]# cat  /etc/NetworkManager/NetworkManager.conf 
# Configuration file for NetworkManager.
#
# See "man 5 NetworkManager.conf" for details.
#
# The directory /etc/NetworkManager/conf.d/ can contain additional configuration
# snippets. Those snippets override the settings from this main file.
#
# The files within conf.d/ directory are read in asciibetical order.
#
# If two files define the same key, the one that is read afterwards will overwrite
# the previous one.

[main]
plugins=ifcfg-rh

dns=none  #添加这句

[logging]
#level=DEBUG
#domains=ALL
   重启NetworkManager
# systemctl restart NetworkManager.service
   修改 /etc/resolv.conf
   nameserver 8.8.8.8

你可能感兴趣的:(linux)