使用curl命令訪問網站時報錯:
[root@bqh-119 ~]# curl -I www.test.com
curl: (7) couldn't connect to host
[root@bqh-119 ~]# curl -V #查詢版本以及支持的協議
curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftp
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz
首先看能ping通網站不,若ping不通,則去/etc/hotst下加解析地址:
然后再查看防火牆是否開啟或是否添加了訪問規則:
關閉防火牆后curl就正常了,很多情況下都是因防火牆規則攔截導致,當然也有其它配置原因導致。