无法从客户机 Ubuntu 16.04 ping 主机 osx

无法从客户机 Ubuntu 16.04 ping 主机 osx

我在我的 osx 机器上通过 VirtualBox 创建了一个 Ubuntu-16.04 VM。我使用了 2 个网络适配器:Bridged Adapter [en0: Wi-Fi (Airport)]Host-only Adapter (vboxnet0)

这是两台机器的 ifconfig o/p,首先是 osx:

en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether 3c:15:c2:c8:27:d0
    inet 192.168.1.5 netmask 0xffffff00 broadcast 192.168.1.255
    media: autoselect
    status: active
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=63<RXCSUM,TXCSUM,TSO4,TSO6>
    ether 3e:15:c2:8c:a2:00
    Configuration:
            id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
            maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
            root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
            ipfilter disabled flags 0x2
    member: en1 flags=3<LEARNING,DISCOVER>
            ifmaxaddr 0 port 5 priority 0 path cost 0
    member: en2 flags=3<LEARNING,DISCOVER>
            ifmaxaddr 0 port 6 priority 0 path cost 0
    media: <unknown type>
    status: inactive
vboxnet0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
    ether 0a:00:27:00:00:00
    inet 192.168.56.1 netmask 0xffffff00 broadcast 192.168.56.255

Ubuntu 下一步:

enp0s3    Link encap:Ethernet  HWaddr 08:00:27:7a:ba:0d
          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::f296:f0:610e:2b37/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8596 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7017 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:7956786 (7.9 MB)  TX bytes:945469 (945.4 KB)

enp0s8    Link encap:Ethernet  HWaddr 08:00:27:b6:c9:6e
          inet addr:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::ba63:3f0e:321:ee37/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:35 errors:0 dropped:0 overruns:0 frame:0
          TX packets:66 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3864 (3.8 KB)  TX bytes:7966 (7.9 KB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1065 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1065 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:100747 (100.7 KB)  TX bytes:100747 (100.7 KB)

我无法从 ubuntu ping osx:

$ ping 192.168.1.5
PING 192.168.1.5 (192.168.1.5) 56(84) bytes of data.
^C
--- 192.168.1.5 ping statistics ---
480 packets transmitted, 0 received, 100% packet loss, time 490401ms

但我可以从 osx ping ubuntu (guest)。我该如何修复这个问题?

Note: Firewall is disabled on both the machines

我刚刚在两台机器上运行了 tcpdumps,这是来自 Guest(Ubuntu)的输出:

inet 127.0.0.1 netmask 0xff000000
$ sudo tcpdump -nni any dst host 192.168.1.5
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
07:18:46.141730 IP 192.168.1.2 > 192.168.1.5: ICMP echo request, id 1992, seq 1, length 64
07:18:47.156510 IP 192.168.1.2 > 192.168.1.5: ICMP echo request, id 1992, seq 2, length 64
07:18:48.179200 IP 192.168.1.2 > 192.168.1.5: ICMP echo request, id 1992, seq 3, length 64
07:18:49.203053 IP 192.168.1.2 > 192.168.1.5: ICMP echo request, id 1992, seq 4, length 64
07:18:50.227545 IP 192.168.1.2 > 192.168.1.5: ICMP echo request, id 1992, seq 5, length 64
07:18:51.251328 IP 192.168.1.2 > 192.168.1.5: ICMP echo request, id 1992, seq 6, length 64
07:18:51.316782 ARP, Request who-has 192.168.1.5 tell 192.168.1.2, length 28

$ sudo tcpdump -nni any src host 192.168.1.5
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
07:19:43.027612 ARP, Reply 192.168.1.5 is-at 3c:15:c2:c8:27:d0, length 46
07:20:25.011455 ARP, Reply 192.168.1.5 is-at 3c:15:c2:c8:27:d0, length 46
^C
2 packets captured
2 packets received by filter
0 packets dropped by kernel

在主机(osx)上:

$ sudo tcpdump -nni any icmp
tcpdump: data link type PKTAP
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type PKTAP (Packet Tap), capture size 65535 bytes
07:59:37.858801 IP 192.168.1.2 > 192.168.1.5: ICMP echo request, id 1941, seq 6, length 64
07:59:38.882701 IP 192.168.1.2 > 192.168.1.5: ICMP echo request, id 1941, seq 7, length 64
07:59:39.905794 IP 192.168.1.2 > 192.168.1.5: ICMP echo request, id 1941, seq 8, length 64
07:59:40.928857 IP 192.168.1.2 > 192.168.1.5: ICMP echo request, id 1941, seq 9, length 64
07:59:41.953113 IP 192.168.1.2 > 192.168.1.5: ICMP echo request, id 1941, seq 10, length 64
07:59:42.975912 IP 192.168.1.2 > 192.168.1.5: ICMP echo request, id 1941, seq 11, length 64

这是否意味着主机确实收到了来自客户机的 ping 请求,但没有对其做出响应?

答案1

您是否尝试过关闭 OS X 防火墙?或者至少确保“启用隐身模式”(系统偏好设置 > 安全和隐私 > 防火墙 > 防火墙选项...)未选中,如下所示。它对我有用,但我没有设置第二个网络适配器。我只设置了一个桥接适配器。

启用隐身模式

相关内容