出现 Could not resolve host: mirror.webtatic.com 的问题通常是因为DNS配置出现错误。
此处我们将会在后面讲解到如何配置DNS··
centos 7配置静态IP,并配置DNS,yum 安装高版本lamp 文件的PHP
centos 7配置静态IP,并配置DNS
cd /etc/sysconfig/network-scripts/
找到对应的网卡配置并编辑 centos7 默认为 ens33
vim ifcfg-ens33
配置其中信息
TYPE=Ethernet
BOOTPROTO=static
#配置静态IP,网关,子网掩码
IPADDR=192.168.10.88
NETMASK=255.255.255.0
GATEWAY=192.168.10.1
取消networkmanager 管理
NM_CONTROLLED=no
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=ens33
UUID=ed246b2b-cc49-4785-a675-feebf70440e7
DEVICE=ens33
ONBOOT=yes
NM_CONTROLLED=no表示该接口不通过网络管理器进行管理,而是通过配置文件管理。“ONBOOT=yes”表示系统将在启动时开启该接口。
我是在虚拟机中配置的,用的桥接方式连接网络,IP的配置和网关可以在虚拟机中编辑–》虚拟网络编辑器中能找到
配置完静态IP后重启网络服务
systemctl restart network.service
此时如果ping百度会显示主机找不到,ping百度IP(180.149.132.47)能ping通,说明DNS没有配置,接下来配置DNS
切到networkmanager目录
cd /etc/NetworkManager/
修改 NetworkManager.conf配置文件
增加
dns=none
通过网络管理器管理
修改resolv.conf,新增dns配置
vim /etc/resolv.conf
#主DNS
nameserver 8.8.8.8
#备DNS
nameserver 8.8.4.4
此时ping baidu.com就能ping通了