我有一个在 VirtualBox 中运行 Ubuntu 的 Vagrant 设置。我正在尝试创建一个可以从主机访问的公共虚拟网络接口。使用 ipv4 执行此操作没有问题。使用 ipv6,我设置接口如下:
guest$ ip link add derpcraft link eth1 type macvlan mode bridge;
guest$ ip -6 addr add fdfe:dcba:9876:ffff::/64 dev derpcraft
guest$ ip link set derpcraft up
界面如下:
derpcraft Link encap:Ethernet HWaddr 26:22:d5:54:95:00
inet6 addr: fe80::2422:d5ff:fe54:9500/64 Scope:Link
inet6 addr: fdfe:dcba:9876:ffff::/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:264 errors:0 dropped:0 overruns:0 frame:0
TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:52989 (52.9 KB) TX bytes:2040 (2.0 KB)
从主机上我似乎无法 ping 通接口上的任何一个地址。
host$ ping6 fe80::2422:d5ff:fe54:9500
ping6: UDP connect: No route to host
host$ ping6 fe80::2422:d5ff:fe54:9500%::1
ping6: UDP connect: No route to host
host$ ping6 fdfe:dcba:9876:ffff::
ping6: UDP connect: No route to host
host$ ping6 fdfe:dcba:9876:ffff::%::1
ping6: UDP connect: No route to host
我想我可能需要配置 Vagrant 或 VirtualBox 来接受 ipv6 连接。
还有一点。我目前的 ISP 还不支持 ipv6。我不怀疑这与此有关,因为这应该都是本地请求。
更新:为了保险起见,我给接口提供了一个 ipv4 地址,例如:
guest$ ip address add 192.168.33.11/24 broadcast 192.168.33.255 dev derpcraft
guest$ ifconfig
derpcraft Link encap:Ethernet HWaddr 26:22:d5:54:95:00
inet addr:192.168.33.11 Bcast:192.168.33.255 Mask:255.255.255.0
inet6 addr: fe80::2422:d5ff:fe54:9500/64 Scope:Link
inet6 addr: fdfe:dcba:9876:ffff::/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1736 errors:0 dropped:0 overruns:0 frame:0
TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:418224 (418.2 KB) TX bytes:2040 (2.0 KB)
我可以从主机 ping 通该命令,没有任何问题:
host$ ping 192.168.33.11
PING 192.168.33.11 (192.168.33.11): 56 data bytes
64 bytes from 192.168.33.11: icmp_seq=0 ttl=64 time=0.497 ms
64 bytes from 192.168.33.11: icmp_seq=1 ttl=64 time=0.426 ms
64 bytes from 192.168.33.11: icmp_seq=2 ttl=64 time=0.388 ms
^C
--- 192.168.33.11 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.388/0.437/0.497/0.045 ms
更新:主机界面如下:
host$ ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=3<RXCSUM,TXCSUM>
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 04:0c:ce:e4:1f:be
inet6 fe80::60c:ceff:fee4:1fbe%en0 prefixlen 64 scopeid 0x4
inet 192.168.1.72 netmask 0xffffff00 broadcast 192.168.1.255
media: autoselect
status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
ether 06:0c:ce:e4:1f:be
media: autoselect
status: inactive
vboxnet0: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 0a:00:27:00:00:00
vboxnet1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 0a:00:27:00:00:01
inet 192.168.33.1 netmask 0xffffff00 broadcast 192.168.33.255
这表明 VirtualBox 接口都没有 inet6,这可能是问题所在,但我不确定如何启用它。
答案1
看起来使用 vagrantspublic_network
选项会将 virtualbox 接口桥接到主机接口,并搭载 IPV6