首页 > 系统服务 > 详细

【Ubuntu日常技巧】VirtualBox多网卡路由配置,保障虚拟机连接上外网

时间:2015-05-02 17:52:16      阅读:356      评论:0      收藏:0      [点我收藏+]

背景】: 配置Ubuntu 虚拟机双网卡,一个是Host-Only网络,一个是桥接网络。当在虚拟机中同时连接到两个网络后,虚拟机能够ping通内部网络,不能ping通外部网络,如www.baidu.com。

技术分享

1. 虚拟机网卡配置

技术分享    技术分享

2. 虚拟机内部网络配置

HostOnly网络配置:                                   

技术分享

桥接网络配置:

技术分享 

3.检查虚拟机网络

 ping不通外网,查看路由表。

 技术分享

失败原因: 发现default路由是HostOnly 的网络,网段是56段的,不能与外网相通;将default路由修改为1段(192.168.1.X)的。

4.修改default路由

dev@dev-VirtualBox:~$ sudo route add default gw 192.168.1.1
dev@dev-VirtualBox:~$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.1     0.0.0.0         UG    0      0        0 eth1
default         192.168.56.1    0.0.0.0         UG    0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     1      0        0 eth1
192.168.56.0    *               255.255.255.0   U     1      0        0 eth0

 

技术分享

 修改后发现有两个default路由,然后出现了Dns,无法进行域名解析。

 解决方案:

 删除56网段的default路由

dev@dev-VirtualBox:~$ sudo route del default gw 192.168.56.1
dev@dev-VirtualBox:~$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.1     0.0.0.0         UG    0      0        0 eth1
192.168.1.0     *               255.255.255.0   U     1      0        0 eth1
192.168.56.0    *               255.255.255.0   U     1      0        0 eth0

 

 技术分享

 

还有一种比较简单的方案,在创建虚拟机网卡时,设置虚拟机网卡顺序为:网卡1 桥接网络; 网卡2HostOnly网络。

 

 

【Ubuntu日常技巧】VirtualBox多网卡路由配置,保障虚拟机连接上外网

原文:http://www.cnblogs.com/QuLory/p/4472135.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!