Linux下设置DNS的位置主要是:shell
1. 网卡设置配置文件里面DNS服务器地址设置。服务器
2. 系统默认DNS服务器地址设置。dom
3. hosts文件指定。spa
生效顺序是:code
1 hosts文件 ----2 网卡配置文件DNS服务地址 ---3 /etc/resolv.conform
# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 HWADDR=00:0C:29:88:30:38 TYPE=Ethernet UUID=7f4bf343-9ffb-45ee-89b3-afd6e874b6b5 ONBOOT=yes NM_CONTROLLED=yes #BOOTPROTO=dhcp BOOTPROTO=static IPADDR=192.168.1.118 NETMASK=255.255.255.0 GATEWAY=192.168.1.1# cat /etc/resolv.conf DNS1=221.228.255.1
nameserver 8.8.8.8