为什么我无法访问虚拟机内部的主机?


0

主持人:cent os 7

ip:192.168.1.3/24 默认路由:192.168.1.1

虚拟接口ip:virbro:192.168.4.0/24网关:192.168.4.2

在主机上IP

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether c0:3f:d5:66:c3:01 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.3/24 brd 192.168.1.255 scope global dynamic eno1
       valid_lft 62703sec preferred_lft 62703sec
    inet6 fe80::c23f:d5ff:fe66:c301/64 scope link 
       valid_lft forever preferred_lft forever
3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether ac:fd:ce:03:2c:58 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.2/24 brd 192.168.1.255 scope global dynamic wlp2s0
       valid_lft 62549sec preferred_lft 62549sec
    inet6 fe80::aefd:ceff:fe03:2c58/64 scope link 
       valid_lft forever preferred_lft forever
4: ham0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1404 qdisc pfifo_fast state UNKNOWN qlen 500
    link/ether 7a:79:19:5c:7b:fd brd ff:ff:ff:ff:ff:ff
    inet 25.92.123.253/8 brd 25.255.255.255 scope global ham0
       valid_lft forever preferred_lft forever
    inet6 2620:9b::195c:7bfd/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::7879:19ff:fe5c:7bfd/64 scope link 
       valid_lft forever preferred_lft forever
5: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
    link/ether 52:54:00:35:f6:c9 brd ff:ff:ff:ff:ff:ff
    inet 192.168.4.0/24 brd 192.168.4.255 scope global virbr0
       valid_lft forever preferred_lft forever
    inet 192.168.4.3/24 scope global secondary virbr0
       valid_lft forever preferred_lft forever
6: virbr0-nic: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 500
    link/ether 52:54:00:35:f6:c9 brd ff:ff:ff:ff:ff:ff

主机上的IP R

[root@centos services]# ip r
default via 192.168.1.1 dev eno1  proto static  metric 100 
default via 192.168.1.1 dev wlp2s0  proto static  metric 600 
25.0.0.0/8 dev ham0  proto kernel  scope link  src 25.92.123.253 
192.168.1.0/24 dev eno1  proto kernel  scope link  src 192.168.1.3  metric 100 
192.168.1.0/24 dev wlp2s0  proto kernel  scope link  src 192.168.1.2  metric 600 
192.168.4.0/24 dev virbr0  proto kernel  scope link  src 192.168.4.0 

对于访客同样:cent os 7

ip:192.168.4.200/24 默认路由:192.168.4.2

来宾上的 ip aip r在此处输入图片说明

我也无法从vm(192.168.4.200)ping主机(192.168.1.3),这使我无法访问目标主机。

编辑:刚刚以vm guest虚拟机的身份安装了Windows,并能够从中ping来宾。

Windows来宾:

 Link-local IPv6 Address . . . . . : fe80::7085:b96
 IPv4 Address. . . . . . . . . . . : 192.168.4.104
 Subnet Mask . . . . . . . . . . . : 255.255.255.0
 Default Gateway . . . . . . . . . : 192.168.4.0

:\Users\IEUser>ping 192.168.1.3

inging 192.168.1.3 with 32 bytes of data:
eply from 192.168.1.3: bytes=32 time<1ms TTL=64
eply from 192.168.1.3: bytes=32 time<1ms TTL=64
eply from 192.168.1.3: bytes=32 time<1ms TTL=64
eply from 192.168.1.3: bytes=32 time<1ms TTL=64

ing statistics for 192.168.1.3:
   Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

主持人:


2
您所显示的只是界面详细信息。请编辑您的问题以添加更多详细信息,例如ping会8.8.8.8怎样?ping时会发生什么google.com?这可能像DNS解析问题一样简单,也可能像整个网络设置一样大,但是您提供的详细信息并不能清楚地说明很多问题。
JakeGould '16

Answers:


0

您必须将ip添加到主机的虚拟nic。

ip a a 192.168.4.3/24 dev virbr0

然后从该IP(192.168.4.3)上的来宾访问主机

要立即解决这两个问题,请确保已在VM虚拟机管理程序上启用NAT。我希望来宾操作系统的默认网关为192.168.4.1。尝试用

ip r d default via 192.168.4.2
ip r a default via 192.168.4.1

如果这不起作用,请为两个系统发送以下命令的结果:

ip a
ip r

刚刚将Windows安装为vm,并能够从其中访问主机。不确定为什么Linux guest
虚拟机
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.