Centos 虚拟机 Could not resolve host

445 阅读1分钟

原文链接 blog.csdn.net/jasonhector…

没有配置DNS会引起的问题

yum命令 ssh命令等不能进行

错误:

Could not resolve host: centos.ustc.edu.cn;

本文例子: CentOS7 下DNS配置

网络适配器设置

image.png

1.root权限登录终端 输入

$ ip add

image.png

ens33 为我的名字 记下

2.查找配置文件

$ cd /etc/sysconfig/network-scripts/

image.png

$ ls

找到刚才对应的名字

image.png

$ vi ifcfg-ens33

最底下 ONBOOT = yes

image.png

3.关机重启,然后ping 一下网站看看是否能通

$ shutdown -r now

百度为例

$ping www.baidu.com

image.png

4.重新查看

$ ip add

image.png

记录下ip地址

5.进行配置文件添加配置

$ cd /etc/sysconfig/network-scripts/

修改原先文件

$ vi ifcfg-ens33

image.png

后两行最后都为1就可以

6.保存退出 重启

$ shutdown -r now

执行yum 操作

$ yum install perl*