crm*_*cco 4 networking centos virtualbox bridge virtual-machine
我的 Windows 7 机器上有一个 VirtualBox CentOS VM 设置。我可以ping我的路由器,但是我无法访问外面的世界。
在 Windows 中,我设置了三个网络连接:
我的 VM 设置为使用桥接适配器通过“戴尔无线适配器”进行连接。
是否有任何原因导致我无法从 VM 访问外部世界?
我正在尝试使用以下命令 ping Google:
平 8.8.8.8
并获得连接:网络无法访问
这是来自 ifconfig 的转储:
eth0 Link encap:Ethernet HWaddr 08:00:27:F2:EF:F7
inet addr:192.168.0.25 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3310 errors:0 dropped:0 overruns:0 frame:0
TX packets:337 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:292875 (286.0 KiB) TX bytes:40593 (39.6 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:249 errors:0 dropped:0 overruns:0 frame:0
TX packets:249 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:20076 (19.6 KiB) TX bytes:20076 (19.6 KiB)
Run Code Online (Sandbox Code Playgroud)
这是来自 route -n 的转储:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
Run Code Online (Sandbox Code Playgroud)
您的路由表不完整。
您的计算机只知道如何路由到与开始IP地址192.168和169.254,但不知道如何路由到任何其他IP,我们会想其他任何IP地址,通过路由器进行路由。
如果您的路由器是192.168.1.1,您可以例如执行:
route add default gw 192.168.1.1
Run Code Online (Sandbox Code Playgroud)
这将导致表格如下所示:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
Run Code Online (Sandbox Code Playgroud)
有关其工作原理的更多信息,请执行man route.