ping:http://google.com:名称或服务未知

时间:2017-04-12 10:21:31

标签: centos7

我在Windows上的virtualbox中使用centos7。并且vagrant发了它,用http或https得到了ping错误。还卷曲。有人可以帮我解决问题并让它发挥作用。

[root@localhost ~]# ping google.com
PING google.com (61.91.161.217) 56(84) bytes of data.
64 bytes from chatenabled.mail.google.com (61.91.161.217): icmp_seq=1 ttl=43 time=404 ms
64 bytes from chatenabled.mail.google.com (61.91.161.217): icmp_seq=2 ttl=43 time=408 ms
64 bytes from chatenabled.mail.google.com (61.91.161.217): icmp_seq=3 ttl=43 time=407 ms
64 bytes from chatenabled.mail.google.com (61.91.161.217): icmp_seq=4 ttl=43 time=408 ms
^C
--- google.com ping statistics ---
5 packets transmitted, 4 received, 20% packet loss, time 4000ms
rtt min/avg/max/mdev = 404.297/407.234/408.956/1.887 ms
[root@localhost ~]# ping https://google.com
ping: https://google.com: Name or service not known
[root@localhost ~]# ping https://61.91.161.217
ping: https://61.91.161.217: Name or service not known

`

resolv.conf

[root@localhost ~]# cat /etc/resolv.conf 
nameserver 10.0.2.3
nameserver 8.8.8.8
nameserver 8.8.4.4
search localhost

`

ifconfig

[root@localhost ~]# ifconfig 
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::5054:ff:fe73:fb1  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:73:0f:b1  txqueuelen 1000  (Ethernet)
        RX packets 610587  bytes 48453952 (46.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 468759  bytes 41290880 (39.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.33.10  netmask 255.255.255.0  broadcast 192.168.33.255
        inet6 fe80::a00:27ff:fe0e:ae16  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:0e:ae:16  txqueuelen 1000  (Ethernet)
        RX packets 3069145  bytes 2674132747 (2.4 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2531212  bytes 213727091 (203.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

从vagrant自动创建的网络文件

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
NAME="eth0"
ONBOOT=yes
NETBOOT=yes
UUID="704aa015-53dd-4ba7-9689-b9b8bf6e09a5"
IPV6INIT=yes
BOOTPROTO=dhcp
TYPE=Ethernet
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
HWADDR=52:54:00:73:0f:b1
DNS1=8.8.8.8
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
NM_CONTROLLED=no
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.33.10
NETMASK=255.255.255.0
DEVICE=eth1
PEERDNS=no
DNS1=8.8.8.8

5 个答案:

答案 0 :(得分:17)

首先确保在虚拟框设置中启用了网络适配器。

您用于连接互联网的网络接口可能无效。

  1. 要检查此项,请使用&#34; sudo nmcli d &#34;命令。

  2. 如果已断开连接,请使用&#34; sudo nmtui &#34; - &gt;编辑连接,选择您的网络接口并选择&#34;自动连接&#34 ;选项(通过 按空格键)并选择确定。

  3. 现在&#34; sudo重新启动&#34;登录后,请执行www.google.com&#34;。

  4. 您现在应该能够连接。

答案 1 :(得分:7)

ping与HTTP或HTTPS无关:

Ping将使用ICMP协议,它属于TCP / IP

Ping通过向目标主机发送Internet控制消息协议(ICMP)回送请求数据包并等待ICMP响应来进行操作。

实际上ping的工作水平远低于HTTP或HTTPS,并且只接受主机名,而不是URL。

答案 2 :(得分:1)

更改VirtualBOx网卡

使用->英特尔PRO / 1000 T服务器(82543GC)

答案 3 :(得分:0)

我尝试了很多不同的解决方案。将resolve.conf更改了十亿次。最后,我只需要重新启动路由器即可。为我解决了,希望对您也一样。

答案 4 :(得分:-2)

检查 /etc/nsswitch.conf 并从下面的行中删除 #

网络:文件#dns