上周, 部分站点出现Couldn't resolve host.....问题,  导致公司所有走api的程序都无法正常使用(系统redhat 6.3的都出现问题, redhat 5一切OK). 最后解决方法找到了,但是具体原因目前还未知.

从这个报错,可以很明显的发现是域名解析不了。于是做如下排查。

1. 故障排除

1. 1 测试域名是否能解析到

简单的使用ping来测试,发现DNS解析是OK。

 
1
2
3
# ping -c 1 www.ttlsa.com
PING www.ttlsa.com (173.255.219.122) 56(84) bytes of data.
64 bytes from rpms.adiscon.com (173.255.219.122): icmp_seq=1 ttl=51 time=222 ms

1.2 测试curl是否有故障

因为php程序调用的是curl,所以我们测试一下curl是否能够正常解析dns

 
1
2
# curl  www.ttlsa.com
curl: (6) Couldn't resolve host 'www.ttlsa.com'

竟然真的不行,这种奇葩问题首次遇到.

2. 解决问题

尝试解决方法:

修改dns

 
1
2
3
4
5
6
# cat /etc/resolv.conf | grep names
nameserver 218.85.157.99
nameserver 218.85.152.99
改为
nameserver 114.114.114.114
nameserver 8.8.8.8

重新测试curl,问题得到解决。

3. ttlsa群友提供解决方法

于此同时,群里的一个福建群友在也反应这个问题,看来应该是电信DNS有调整的缘故,但是具体的原因还是不得而知。告知其修改dns,问题也得到解决。

今天ttlsa群里的"福州 - 要上天"(藏得很深很低调的大牛)询问此问题是否解决,并提供另外的解决方法。

3.1 执行curl指定ipv4

 
1
curl -4 www.baidu.com

3.2 关闭ipv6

请参考CentOS6 / RHCE6 禁用IPv6协议模块:http://www.ttlsa.com/html/3640.html

如果是php程序,那么请在使用curl的时候指定ipv4的参数:CURL_IPRESOLVE_V4

感谢群友提供的解决方案. 如果你也遇到如上问题,不烦尝试下上面的解决方案.

 4. curl无法解析原因

本文发出之后, 咱们ttlsa群主"north-boy"也找到原因所在,并且在“CentOS6 / RHCE6 禁用IPv6协议模块”提到,请看网址:http://www.ttlsa.com/html/3640.html

站点:运维生存时间   网址:http://www.ttlsa.com/html/3631.html

转自

curl: (6) Couldn’t resolve host ‘www.ttlsa.com’ – 运维生存时间
http://www.ttlsa.com/linux/curl-6-couldnt-resolve-host/

curl: (6) Couldn’t resolve host ‘www.ttlsa.com’【转】的更多相关文章

  1. curl: (6) Couldn’t resolve host ‘www.ttlsa.com’

      上周, 部分站点出现Couldn't resolve host.....问题,  导致公司所有走api的程序都无法正常使用(系统redhat 6.3的都出现问题, redhat 5一切OK). 最 ...

  2. CentOS报错:Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock32 error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

    今天安装完带图形界面的CentOS 7后,在Terminal中运行yum安装命令时报了以下错误: Could not retrieve mirrorlist http://mirrorlist.cen ...

  3. Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock32 error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

     今天安装完带图形界面的CentOS 7后,在Terminal中运行yum安装命令时报了以下错误: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...

  4. curl: (6) Could not resolve host: www.baidu.com;

    今天,在执行curl时,突然发现这个报错,问题是之前完全没有出现过这样的情况. [root@localhost ~]# curl www.baidu.comcurl: (6) Could not re ...

  5. yum 安装报错:Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

    [root@venn09 ~]# yum install -y vim Loaded plugins: fastestmirror Could not retrieve mirrorlist http ...

  6. yum安装软件报错:curl#6 - "Could not resolve host: mirrorlist.centos.org; Temporary failure in name resolut

    # yum install -y epel-release Loaded plugins: fastestmirror Repository base is listed more than once ...

  7. 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"

    14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误" One of the configured ...

  8. url: (6) Couldn’t resolve host ‘www.ttlsa.com’

    http://www.ttlsa.com/linux/curl-6-couldnt-resolve-host/ 2. 解决问题 尝试解决方法: 修改dns # cat /etc/resolv.conf ...

  9. 『cURL』curl: (6) Could not resolve host无法解析主机地址

    最近在学数据挖掘时,获取数据有两种途径: 开放数据,可以直接使用和存储的数据: 网络数据,通过爬虫或云市场api(付费或免费)获取数据 我通过教程,在阿里云购买一个天气数据api,尝试使用cURL获取 ...

随机推荐

  1. 使用cookie保存用户登录信息

    写入Cookie HttpCookie _cookie = new HttpCookie("User"); _cookie.Values.Add("UserName&qu ...

  2. BZOJ3613 HEOI2014南园满地堆轻絮

    不明白在某谷上是怎么标到紫的.二分答案或者发现答案就是最大逆序差的一半. #include<iostream> #include<cstdio> #include<cma ...

  3. Django获取多个数据及文件上传

    1. 选择性别: 1)更新login.html模板 2)views.py中获取客户端提交的数据 3)当选择性别为“男”后,后台得到了gender=1. 2.选择爱好,可以多选,所以后台会获得多个数据. ...

  4. URAL1519:Formula 1——题解

    http://acm.timus.ru/problem.aspx?space=1&num=1519 https://vjudge.net/problem/URAL-1519 题目大意:给一个网 ...

  5. Git之安装及使用

    学习使用Git来管理平时自己写的demo代码和阅读的一些源码,因为一直在windows中操作所以开始学习用Git Bash操作在github上的代码.git命令和svn命令是很相似的,我觉得没有必要把 ...

  6. python学习笔记(三)高级特性

    一.切片 list.tuple常常截取某一段元素,截取某一段元素的操作很常用 ,所以python提供了切片功能. L=['a','b','c','d','e','f'] #取索引0,到索引3的元素,不 ...

  7. 防止apk反编译的技术分析浅谈--内存修改器篇

    声明: 1.本帖转载自http://jingyan.baidu.com/article/a24b33cd509eb719fe002b94.html,仅供自用,勿喷 Apk反编译修改器有很多.拿其中的比 ...

  8. socketserver多线程处理

    一.简介 SocketServer简化了网络服务器的编写.在进行socket创建时,使用SocketServer会大大减少创建的步骤,并且SocketServer使用了select它有5个类:Base ...

  9. mysql 自动记录数据插入及最后修改时间

    总结: `uptime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 原文 应用场景: 1.在数据 ...

  10. JS笔记加强版3

    JS 面向对象及组件开发   JS的面向对象:   1.什么是面向对象编程   用对象的思想去写代码,就是面向对象编程 过程式写法 面向对象写法 我们一直都在使用对象 数组 Array 时间 Date ...