我有两台虚拟机
cdp: 192.168.64.5
ubuntu@cdp:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
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: enp0s1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 52:54:00:8c:10:91 brd ff:ff:ff:ff:ff:ff
inet 192.168.64.5/24 brd 192.168.64.255 scope global dynamic enp0s1
valid_lft 78881sec preferred_lft 78881sec
inet6 fd96:bec8:dc5e:d1c1:5054:ff:fe8c:1091/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 2591889sec preferred_lft 604689sec
inet6 fe80::5054:ff:fe8c:1091/64 scope link
valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:ee:b9:4f:99 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
ubuntu@cdp:~$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.64.1 0.0.0.0 UG 100 0 0 enp0s1
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
192.168.64.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s1
192.168.64.1 0.0.0.0 255.255.255.255 UH 100 0 0 enp0s1
lab: 192.168.64.6
ubuntu@lab:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
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: enp0s1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 52:54:00:eb:e8:7b brd ff:ff:ff:ff:ff:ff
inet 192.168.64.6/24 brd 192.168.64.255 scope global dynamic enp0s1
valid_lft 78849sec preferred_lft 78849sec
inet6 fd96:bec8:dc5e:d1c1:5054:ff:feeb:e87b/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 2591990sec preferred_lft 604790sec
inet6 fe80::5054:ff:feeb:e87b/64 scope link
valid_lft forever preferred_lft forever
3: dum0: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
link/ether 4a:c8:c0:64:e9:97 brd ff:ff:ff:ff:ff:ff
inet 192.168.64.10/24 brd 192.168.64.255 scope global dum0
valid_lft forever preferred_lft forever
inet6 fe80::48c8:c0ff:fe64:e997/64 scope link
valid_lft forever preferred_lft forever
ubuntu@lab:~$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.64.1 0.0.0.0 UG 100 0 0 enp0s1
192.168.64.0 0.0.0.0 255.255.255.0 U 0 0 0 dum0
192.168.64.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s1
192.168.64.1 0.0.0.0 255.255.255.255 UH 100 0 0 enp0s1
然后我的主机 ip 是 192.168.64.1 。两台虚拟机是可以与主机互相连通的,但是两台虚拟机之间无法联通,出现 ping 超时的情况
而且,从两台虚拟机 ping 公网 ip ,比如百度,是可以通的。我用 arp 命令查看了一下,发现两台虚拟机都获取到了对方的 mac 地址
ubuntu@cdp:~$ arp -a
_gateway (192.168.64.1) at f6:d4:88:98:8c:64 [ether] on enp0s1
? (192.168.64.6) at 52:54:00:eb:e8:7b [ether] on enp0s1
而且,两台机器的 iptables 没有拦截的规则
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.