在虚拟机上安装的CentOS,但是当执行ping命令的时候,提示name or service not known

解决方法如下:

1. 添加DNS服务器

vi /etc/resolv.conf
  • 1

在文件中添加如下两行(可以自己选择DNS服务器,这里选的是114的,包括谷歌的8.8.8.8和腾讯的119.29.29.29都可以):

nameserver 114.114.114.114
nameserver 114.114.114.115
  • 1
  • 2

两行分别是首选DNS服务器和备选DNS服务器。
:wq保存退出,直接就可以使用。
如果还不好使,接着向下看。

2. 设置一个配置文件:

进入到/etc/sysconfig/network-scprits/打开ifcfg-ens33文件(这个文件名称不同的客户端可能会不同,我的是ens33,也有的是ens0或者是加上其他数字)

vi /etc/sysconfig/network-scprits/ifcfg-ens33
  • 1

在文件中,找到 ONBOOT=NO 改成 ONBOOT=yes

:wq保存退出

重启网络:

service network restart
  • 1

输入执行

ping www.baidu.com
  • 1

完美执行!!!

--------------------- 本文来自 In_new 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/qq_38663729/article/details/80273092?utm_source=copy

CentOS执行ping命令报错 name or service not know的更多相关文章

  1. Linux系统下ping命令报错 name or service not know

    问题描述 CentOS,但是当执行ping命令的时候,提示name or service not known 解决方法 1.添加DNS服务器 vi /etc/resolv.conf 进入编辑模式,增加 ...

  2. Python3安装Celery模块后执行Celery命令报错

    1 Python3安装Celery模块后执行Celery命令报错 pip3 install celery # 安装正常,但是执行celery 命令的时候提示没有_ssl模块什么的 手动在Python解 ...

  3. 关于ubuntu上执行错误命令报错

    Sorry, command-not-found has crashed! 新安装了一台ubuntu server 安装时用中文安装的,之后命令行下各种乱码,最后也不知道是修改哪里造成的 每次执行一次 ...

  4. 安装atlas后执行hive命令报错

    在集群中安装atlas,在安装atlas的节点上执行hive -e "show databases;" 正常,但是在集群中其他节点上执行hive -e "show dat ...

  5. Jenkins中执行docker命令报错

    Cannot connect to the Docker daemon. Is the docker daemon running on this host?   在配置Jenkins从Gitlab自 ...

  6. hbase shell中执行list命令报错:ERROR: org.apache.hadoop.hbase.PleaseHoldException: Master is initializing

    问题描述: 今天在测试环境中,搭建hbase环境,执行list命令之后,报错: hbase(main):001:0> list TABLE ERROR: org.apache.hadoop.hb ...

  7. 执行 maven 命令 报错Unable to add module to the current project as it is not of packaging type 'pom'[转]

    今天学习在本地搭建Maven工程时,执行了mvn archetype:generate 命令,报错. Unable to create project from archetype [org.apac ...

  8. 执行yum命令报错"Unable to connect to Registration Management Service"

    问题描述 linux上执行yum相关命令时,报无法连接到注册管理服务的错误,具体报错信息如下 [root@aijihe-core-zy-2-3 ~]# yum install gcc Loaded p ...

  9. 执行openstack命令报错【You must provide a username via either -...】

    openstack环境搭建好后,openstack的服务都启动了,当执行openstack命令时如nova service list报如下错误 You must provide a username ...

随机推荐

  1. 腾讯云服务器 离线安装最新稳定版MariaDB 10.2.6

    数据库方面我们一般都是使用mysql,由于前段时间我们切换到了MariaDB后,当然生产环境也要更着变,谁叫oracle是个碧池呢! mariaDB主要有三种安装方式 源码安装,有点繁琐,不推荐 yu ...

  2. android笔记--加载框

    package com.fuda.ui; import android.app.Activity; import android.os.Bundle; import android.os.Handle ...

  3. [CoreOS 转载]CoreOS实践指南(二):架设CoreOS集群

    转载:http://www.csdn.net/article/2015-01-04/2823399 摘要:CoreOS是一个采用了高度精简的系统内核及外围定制的操作系统.ThoughtWorks的软件 ...

  4. [Windows Azure] What is Windows Azure Active Directory?

    What is Windows Azure Active Directory? Windows Azure Active Directory is a service that provides id ...

  5. (原创)composite模式和bridge模式是天生的好朋友

    composite模式的意图是:将对象组合成树形结构以表示“部分-整体”的层次结构.composite使得用户对单个对象和组合对象的使用具有一致性.它的类图如下: composite模式的实现分为透明 ...

  6. GDB 调试解析

    GDB(GNU Debugger)是一个强大的命令行调试工具.大家知道命令行的强大就是在于,其可以形成执行序 列,形成脚本.UNIX下的软件全是命令行的,这给程序开发提代供了极大的便利,命令行软件的优 ...

  7. javascript基础拾遗(六)

    1.Date内置对象 获取系统时间 var now = new Date() console.log(now) console.log(now.getDate()) console.log(now.g ...

  8. CSAPP 读书笔记 - 2.31练习题

    根据等式(2-14) 假如w = 4 数值范围在-8 ~ 7之间 2^w = 16 x = 5, y = 4的情况下面 x + y = 9 >=2 ^(w-1)  属于第一种情况 sum = x ...

  9. CSS实现:标题两侧画线效果

    如图: html代码: <div class="detail-news"> <h5 class="detail-news-title"> ...

  10. 在python3.3后urllib2已经不能再用,只能用urllib.request来代替

    版权声明:本文为博主原创文章,未经博主允许不得转载. 在python3.3后urllib2已经不能再用,只能用urllib.request来代替 response=urllib2.urlopen(' ...