如果某台Linux服务器ping不通域名, 如下提示: 

[root@localhost ~]# ping www.baidu.com

ping: unknown host www.baidu.com

首先确定已经连接上路由器,并且路由器能够访问外网,可以通过访问网关进行确定

[root@localhost ~]# ping 8.8.8.8

PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.

64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=2.96 ms

64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.75 ms

如果确定网络没问题的情况下, 可以通过如下步骤寻找解决办法: 

1) 确定设置了域名服务器, 没有的话, 建议设置Google的公共DNS服务, 它应该不会出问题的

[root@localhost ~]# cat /etc/resolv.conf

search localdomain

因为我的DNS没有设置所以导致了ping外网ping不通。将dns添加到该文件中

[root@localhost ~]# vi /etc/resolv.conf

nameserver 202.98.96.68

nameserver 61.139.2.69

~

或者加入192.168.1.1 (默认网关)

2) 确保网关已设置

# grep GATEWAY /etc/sysconfig/network-scripts/ifcfg* 

——————————————————————- 

/etc/sysconfig/network-scripts/ifcfg-eth0:GATEWAY=192.168.40.1 

——————————————————————-

如果未设置, 则通过如下方式增加网关:

# route add default gw 192.168.40.1

或者手工编写/etc/sysconfig/network-scripts/ifcfg*文件后, 重启network服务:

# service network restart

3) 确保可用dns解析

# grep hosts /etc/nsswitch.conf 

——————————————————————- 

hosts:      files dns 

——————————————————————-

如果以上哪个有问题, 修正后, 再测试, 应该就没问题了:

#ping -c 3 www.baidu.com 

PING www.a.shifen.com (220.181.6.175) 56(84) bytes of data. 

64 bytes from 220.181.6.175: icmp_seq=0 ttl=50 time=9.51 ms 

64 bytes from 220.181.6.175: icmp_seq=1 ttl=50 time=8.45 ms 

64 bytes from 220.181.6.175: icmp_seq=2 ttl=50 time=8.97 ms 

— www.a.shifen.com ping statistics — 

3 packets transmitted, 3 received, 0% packet loss, time 2002ms 

rtt min/avg/max/mdev = 8.450/8.977/9.511/0.446 ms, pipe 2

原文地址:https://blog.csdn.net/qq_35370485/article/details/77844860

原 Linux:ping不通baidu.com的更多相关文章

  1. Linux ping不通百度的解决方法

    今天在学习DNS的时候遇到了一个问题,我的虚拟机能够ping通ip地址,却ping不通www.baidu.com www.qq.com等域名,先是出现了以下报错: 折腾了几个小时终于找到解决办法 1. ...

  2. Linux ping不通外网

    在linux中ping www.baidu.com 无法ping通,可能原因是DNS没配置好 方法一: 修改vi /etc/resolv.conf  增加如下内容: nameserver 114.11 ...

  3. VMware虚拟机中red hat linux ping不通宿主物理主机原因

    在VMware Workstation中安装了red hat enterprise linux系统,网络使用“桥接”形式,最后出现在Windows下能够Ping通虚拟主机,而虚拟主机Ping不通Win ...

  4. VMware下配置Linux IP,解决Linux ping不通

    因为安装好VMware8.0后,把VMware服务都设成手动的了,导致有些功能不好使,费了半天劲, 如果安装Linux时选择DHCP自动分配IP,需要启动服务: VMware DHCP service ...

  5. Linux ping 不通 域名 添加DNS

    修改路由配置文件 vi /etc/resolv.conf # Generated by NetworkManager #NDS nameserver 192.168.32.2 redhat7 系统优化 ...

  6. centos虚拟机Ping不通网关

    centos虚拟机Ping不通网关 今天在VMware中安装了centos mini版本,安装完成后,用xshell连接一直连不上,本来以为是mini版本没有安装ssh server,于是就用命令: ...

  7. linux:ping不通www.baidu.com

    如果某台Linux服务器ping不通域名, 如下提示: [root@localhost ~]# ping www.baidu.com ping: unknown host www.baidu.com ...

  8. Linux安装centos,网络net8模式ping不通www.baidu.com或者ping不通主机

    1.Linux安装centos,网络net8模式ping不通www.baidu.com或者ping不通主机. 我使用的是net8模式.配置如下所示,保证可以ping通www.baidu.com或者pi ...

  9. 【Linux】【通信】1.ping不通

    关于为什么ping不通有很多种原因,但直接的表象就网络之间没有成功进行通讯: 在构建虚拟机和win之间的交互时,主要使用了3种网络模式: 桥接bridge VMnet0 主机host     VMne ...

随机推荐

  1. Leetcode830.Positions of Large Groups较大分组的位置

    在一个由小写字母构成的字符串 S 中,包含由一些连续的相同字符所构成的分组. 例如,在字符串 S = "abbxxxxzyy" 中,就含有 "a", " ...

  2. DCOJ5117 set

    题目描述 给定一个数集 A,要求构造一个数集 B,满足: • 对于 A 集合中任意的数 x,x 属于 B,即 A ⊆ B: • 对于 B 集合中任意的数 a, b,(a + b) mod p 属于 B ...

  3. JavaScript--自调用函数(小闭包)

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 【NS2】ns2 otcl与c++关联(转载)

    最近几天,对ns2进行研究,ns2为什么要使用两种语言,因为C++执行速度快,因此对于一些不需要经常改变的东西:例如包的发送.而对于需要经常进行修改的就不能够使用C++,而使用OTcl脚本语言.所有O ...

  5. input禁止复制、粘贴、剪切

    <input type="text" autocomplete="off"> <!-- autocomplete="off" ...

  6. Autodesk 卸载工具,一键完全彻底卸载删除autodesk软件专门卸载工具

    autodesk卸载工具(AUTO Uninstaller)是专门为了针对autodesk类软件卸载不干净而导致autodesk安装失败问题进行研发的autodesk一键卸载工具.现在虽然360或一些 ...

  7. UVa 10323 【数学】

    UVa 10323 题目:计算阶乘在10000~6227020800之间的值,不在范围对应输出Under或者Over. 分析:简单题.数论.因为13!=6227020800,7!<10000&l ...

  8. MongoDB -- JAVA基本API操作

    package com.example.mongodb.mongodb.demo; import com.mongodb.MongoClient; import com.mongodb.client. ...

  9. AIDL基本用法

    1. AIDL有什么用?用TA到目的是什么? 2. 怎么用AIDL? 1. AIDL有什么用? 1.1. 为了提高代码执行速度,将部分逻辑封入C/C++代码中  1.2. 为了调用这部分代码,使用JN ...

  10. LeetCode75 Sort Colors

    题目: Given an array with n objects colored red, white or blue, sort them so that objects of the same ...