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