设为首页 收藏本站
查看: 1063|回复: 0

[经验分享] Ubuntu 7.04下Virtualbox安装及网络桥接

[复制链接]

尚未签到

发表于 2016-1-10 16:29:45 | 显示全部楼层 |阅读模式
一、安装
1. 下载安装包。建议下载 Deb 包。
2. 准备依赖。VirtualBox 的正常使用需要 libxalan110 和 libxerces27 这两个包。所以,你要先行安装它们,可以使用下面的指令:
sudo apt-get install libxalan110 libxerces27
3. 安装编译工具及相关包。在安装过程中,要编译 VirtualBox 所用的内核模块。为此,你需要准备基本的编译工具及包,你可以使用下列指令来安装它们:
sudo apt-get install build-essential linux-headers-`uname -r`
4. 现在,转到所保存 VirtualBox 安装包的目录,通过下面的指令来安装它:
sudo dpkg -i VirtualBox_1.x.x_Ubuntu_feisty_i386.deb
在安装的过程中,VirtualBox 会要求你接受许可协议。另外,安装程序也会创建 vboxusers 用户组,并编译所需的内核模块。
5. 现在,你还不能启动 VirtualBox,因为你的当前用户还不属于 vboxusers 用户组。你可以使用下面的指令来将当前的用户(请使用你的用户名代替指令中的“youruser”)添加到 vboxusers 用户组中:
sudo adduser youruser vboxusers
virtualbox 屏幕下移问题:
如果虚拟机的分辨率接近x的分辨率而导致部分界面在x边沿时,全屏后原来窗口管理器 title 的地方变为黑色条状区域,屏幕下移,windows的开始菜单显示在下一个桌面。
解决方法:全屏前把分辨率调小,全屏后右键把显示器分辨率调到同x一致,这样就不会有屏幕偏移。
二、桥接网络配置
一般而言,安装完VirtualBox设定网路时选择默认的NAT模式,Guest就可顺利联网了,但是这种方式比较死板,要作更有弹性的变化,应该采用桥接模式(Bridged),这里的桥接模式就如同VMware中的Bridged模式,Host与Guest在局域网(LAN)中的地位是相等的。
参考 virtualbox 安装后放在 VirtualBox 目录中的用户手册文件 UserManual.pdf 配置如下:
1. 在基于 Debian 和 Ubuntu 的系统上,首先要安装含有建立虚拟网络设备 ( TAP interfaces ) 的工具 uml-utilities 和桥接工具 bridge-utils:
sudo apt-get install uml-utilities
sudo apt-get install bridge-utils
为了使你的虚拟机能够访问网络接口,你必须将运行虚拟主机的用户的用户名(通常是你的ubuntu登录用户名)添加到uml-net用户组(请用你的用户名替换其中的“vboxuser”):
sudo gpasswd -a vboxuser uml-net
注意:为了使改动生效,请重新启动你的电脑。
2. 向你的 Debian 或者 ubuntu 操作系统描述你要添加的虚拟网络设备,编辑 /etc/network/interfaces:
sudo vim /etc/network/interfaces
在打开的文件后面添加下面的内容,将虚拟网络接口命名为 "tap0",指定该接口IP配置方法为手动,并指定使用该接口的用户(请用你的用户名替换其中的 "vboxuser"):
auto tap0
iface tap0 inet manual
up ifconfig $IFACE 0.0.0.0 up
down ifconfig $IFACE down
tunctl_user vboxuser
3. 首次使用需要激活刚才建立的虚拟网络接口和网络桥:
sudo /sbin/ifup tap0
sudo /sbin/ifup br0
这个步骤只需要做一次,下次主机重新启动时,这个接口和桥将自动激活。
4. 另外还需要在 /etc/network/interfaces 中加入如下内容,建立一个名叫 "br0" 的桥,该桥的IP配置方法为通过DHCP配置,主机中的所有网络接口,也包括tap0这个虚拟网络接口,都将建立在这个桥之上:
auto br0
iface br0 inet dhcp
bridge_ports all tap0
在这里你可以根据自己的网络状况做相应的更改,你可以使网络桥使用静态 IP:
iface br0 inet static
address 192.168.1.2
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
5. 让 virtualbox 使用这个虚拟网络接口,启动 virtualbox,在主界面上选中要使用刚才建立的虚拟网络接口tap0的虚拟机,点“设置”,在弹出的窗口中选“网络”,选中其中一块网卡(通常为 “网络适配器 0”),选中“启用网络适配器”,“连接到”后面选 "Host Interface",选中“接入网线”,然后在“主机网络界面名称”中填入刚才建立的虚拟网络接口的名字 "tap0",确定。同样的你也可以使用 VBoxManage 的命令行工具(将 "My VM" 换成你的虚拟机名字 ):
VBoxManage modifyvm "My VM" -hostifdev1 tap0
最后,配置主机和虚拟机的网络,使主机和虚拟机在同一个网段,这样主机和虚拟机就成了局域网中地位相同的两台机器了,可以互相访问了。
三、撤销网络桥
1. 禁用网桥和虚拟网卡:
sudo /sbin/ifdown br0
sudo /sbin/ifdown tap0
2. 将前面修改的 /etc/network/interfaces 文件还原。
Debian 和 Ubuntu 下 virtualbox 桥接设置原文:
6.5.1.1 Debian and Ubuntu hosts
To set up a permanent host interface on a Debian or Ubuntu host, follow these steps:
1. On modern Debian and Ubuntu based hosts, you must first install the UserMode Linux utilities package (uml-utilities), which contains tools to create TAP interfaces, as well as the bridge utilities (bridge-utils). package. You can do this from the command line using
sudo apt-get install uml-utilities
sudo apt-get install bridge-utils
In order for VirtualBox to be able to access the interface, the user who will be running the virtual machine must be added to the group uml-net, for example with the following command (replace vboxuser with your user name):
sudo gpasswd -a vboxuser uml-net
You may have to log out and log in again for the change to take effect.
2. To describe the TAP interface to your Debian or Ubuntu system, add an entry to the file /etc/network/interfaces. This names the the interface and must also specify the user who will be running the virtual machine using the interface. The following sample entry creates the interface tap0 for the user vboxuser (again, replace with your user name):
auto tap0
iface tap0 inet manual
up ifconfig $IFACE 0.0.0.0 up
down ifconfig $IFACE down
tunctl_user vboxuser
You will probably want to change the entry based on your networking needs. On the host, you will find more documentation in these files:
a) /usr/share/doc/uml-utilities/README.Debian and
b) /usr/share/doc/ifupdown/examples/network-interfaces.gz.
3. The first time it is used, activate the new interface and the bridge with these two commands:
sudo /sbin/ifup tap0
sudo /sbin/ifup br0
This is only needed once, however; the next time the host is restarted, the interface and the bridge should be activated automatically.
4. Another entry must be added to the file /etc/network/interfaces to describe the bridge. The following sample entry creates a bridge called br0, adds to it all ethernet interfaces on the host as well as the TAP interface created above and tells it to obtain an IP address using DHCP so that the host remains able to access the network.
auto br0
iface br0 inet dhcp
bridge_ports all tap0
Again, you will probably want to change this to suit your own networking needs. In particular, you may want to assign a static IP address to the bridge, or if you are using TAP interfaces created by VirtualBox (these are described later), you will want to remove tap0 from the last line. On the host, you will find more documentation in the files
a) /usr/share/doc/bridge-utilities/README.Debian.gz and
b) /usr/share/doc/ifupdown/examples/network-interfaces.gz.
5. To tell VirtualBox to use the interface, select the virtual machine which is to use it in the main window of the VirtualBox application, configure one of its network adaptors to use Host Interface Networking (using "Settings", "Network",“Attached to”) and enter “tap0” into the “Interface name” field. Alternatively, you can use the VBoxManage command line tool (in this example we are attaching the interface to the first network card of the virtual machine ("My VM"):
VBoxManage modifyvm "My VM" -hostifdev1 tap0

本文转自
http://soft.zdnet.com.cn/software_zone/2007/1006/537437.shtml

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-162651-1-1.html 上篇帖子: Windows环境下VirtualBox用VBoxManage命令压缩vdi文件的大小 下篇帖子: 如何安装VirtualBox Linux Guest Additions和Xorg配置(翻译)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表