curl: (6) 无法解析主机:google.com;名称或服务未知 [英] curl: (6) Could not resolve host: google.com; Name or service not known

查看:116
本文介绍了curl: (6) 无法解析主机:google.com;名称或服务未知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试将网页加载到终端时,它给出 curl: (6) 无法解析主机 错误.

when I try to load a web page to terminal it gives curl: (6) Could not resolve host error.

我的 PC 上有互联网,正在尝试使用我的家庭互联网连接.所以我这里不涉及任何代理.

I have internet in my PC and trying from my home internet connection. So as I there is no any proxy involve here.

[root@localhost kevin]# curl http://google.com
curl: (6) Could not resolve host: google.com; Name or service not known

clean all 并再次尝试但不走运.

clean all and tried again but no lucky.

但是如果我使用 IP 而不是域名,它就可以正常工作.

But if I use IP instead of the domain name, it works fine.

[root@localhost kevin]# curl http://173.194.46.0

请问有什么线索吗?

推荐答案

问题是:

  1. 启用 IPV6
  2. 错误的 DNS 服务器

这是我修复它的方法:

IPV6 禁用

  • 打开终端
  • 输入su并回车以超级用户身份登录
  • 输入root密码
  • 输入 cd/etc/modprobe.d/ 将目录切换到 /etc/modprobe.d/
  • 输入 vi disableipv6.conf 在那里创建一个新文件
  • Esc + i 将数据插入文件
  • 在文件中输入install ipv6/bin/true 避免加载IPV6相关模块
  • 输入Esc + :然后wq保存退出
  • 输入 reboot 重新启动 fedora
  • 重启后打开终端并输入 lsmod |grep ipv6
  • 如果没有结果,则表示您正确禁用了 IPV6
  • Open Terminal
  • Type su and enter to log in as the super user
  • Enter the root password
  • Type cd /etc/modprobe.d/ to change directory to /etc/modprobe.d/
  • Type vi disableipv6.conf to create a new file there
  • Press Esc + i to insert data to file
  • Type install ipv6 /bin/true on the file to avoid loading IPV6 related modules
  • Type Esc + : and then wq for save and exit
  • Type reboot to restart fedora
  • After reboot open terminal and type lsmod | grep ipv6
  • If no result, it means you properly disabled IPV6

添加 Google DNS 服务器

  • 打开终端
  • 输入su并回车以超级用户身份登录
  • 输入root密码
  • 输入 cat/etc/resolv.conf 以检查您的 Fedora 使用的 DNS 服务器.这通常是您的调制解调器 IP 地址.
  • 现在我们必须找到一个强大的 DNS 服务器.幸运的是,Google 维护了一个开放的 DNS 服务器.
  • 转到此页面,了解什么是Google公共 DNS IP 地址"
  • 今天是 8.8.8.88.8.4.4.但未来这些可能会发生变化.
  • 输入 vi/etc/resolv.conf 编辑 resolv.conf 文件
  • Esc + i 将数据插入文件
  • 通过在每行的开头插入 # 来注释文件中的所有内容.不要删除任何内容,因为将来可能会有用.
  • 在文件的两行下面输入

  • Open Terminal
  • Type su and enter to log in as the super user
  • Enter the root password
  • Type cat /etc/resolv.conf to check what DNS server your Fedora using. Mostly this will be your Modem IP address.
  • Now we have to Find a powerful DNS server. Luckily there is a open DNS server maintain by Google.
  • Go to this page and find out what are the "Google Public DNS IP addresses"
  • Today those are 8.8.8.8 and 8.8.4.4. But in future those may change.
  • Type vi /etc/resolv.conf to edit the resolv.conf file
  • Press Esc + i for insert data to file
  • Comment all the things in the file by inserting # at the begin of the each line. Do not delete anything because can be useful in future.
  • Type below two lines in the file

域名服务器 8.8.8.8
域名服务器 8.8.4.4

nameserver 8.8.8.8
nameserver 8.8.4.4

-输入 Esc + : 然后 wq 保存退出

-Type Esc + : and then wq for save and exit

这是我的博客文章:http://codeketchup.blogspot.sg/2014/07/how-to-fix-curl-6-could-not-resolve.html

这篇关于curl: (6) 无法解析主机:google.com;名称或服务未知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆