curl: (6) Couldn’t resolve host ‘www.ttlsa.com’
2015-08-03 17:31
519 查看
上周, 部分站点出现Couldn't resolve host.....问题, 导致公司所有走api的程序都无法正常使用(系统redhat 6.3的都出现问题, redhat 5一切OK). 最后解决方法找到了,但是具体原因目前还未知.
从这个报错,可以很明显的发现是域名解析不了。于是做如下排查。
1. 故障排除
1. 1 测试域名是否能解析到
简单的使用ping来测试,发现DNS解析是OK。
# 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
# curl www.ttlsa.com
curl: (6) Couldn't resolve host 'www.ttlsa.com'
竟然真的不行,这种奇葩问题首次遇到.
2. 解决问题
尝试解决方法:
修改dns
# 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
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
从这个报错,可以很明显的发现是域名解析不了。于是做如下排查。
1. 故障排除
1. 1 测试域名是否能解析到
简单的使用ping来测试,发现DNS解析是OK。
# 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 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 |
因为php程序调用的是curl,所以我们测试一下curl是否能够正常解析dns
# curl www.ttlsa.com
curl: (6) Couldn't resolve host 'www.ttlsa.com'
1 2 | # curl www.ttlsa.com curl: (6) Couldn't resolve host 'www.ttlsa.com' |
2. 解决问题
尝试解决方法:
修改dns
# 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
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 |
3. ttlsa群友提供解决方法
于此同时,群里的一个福建群友在也反应这个问题,看来应该是电信DNS有调整的缘故,但是具体的原因还是不得而知。告知其修改dns,问题也得到解决。
今天ttlsa群里的"福州 - 要上天"(藏得很深很低调的大牛)询问此问题是否解决,并提供另外的解决方法。
3.1 执行curl指定ipv4
curl -4 www.baidu.com
1 | curl -4 www.baidu.com |
请参考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
相关文章推荐
- (转)Performance Tunning for Tile-Based Architecture Tile-Based架构下的性能调校
- HDU4101 Ali and Baba (bfs+dfs+博弈)
- lintcode Recover Rotated Sorted Array
- WebX5 Data判断当前行的值是否改变,以及改变当前行的状态
- POJ 2492 A Bug's Life (并查集)
- 内部类中class声明地方不同,效果不一样
- 自定义 Spring Security 4 的UserDetailsService和UserDetails
- 1.9-selinux介绍
- easyui-accordion动态生成菜单的实现
- 如何实现一个checkbox选择框
- Mysql_存储功能
- magento的url中 去掉多余的目录层级
- IO重定向 > >> <
- UVa 1511 - Soju
- 2.2&2.3 Variables
- CSS3中的clip-path使用攻略
- 内存(堆)的动态申请和释放
- 1.8-抓包工具tcpdump和tshark
- PHP中try{}catch{}的具体用法详解
- leetcode-232-Implement Queue using Stacks