免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2210 | 回复: 0
打印 上一主题 下一主题

virtualbox host interface 方式网络设置 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-11-04 23:25 |只看该作者 |倒序浏览
   我分别用了linux版的virtualbox及vmware, 在客机安装为windows XP是, 在虚拟机中对共享文件夹进行写操作时,经常出问题,比如,用word是,常提示内存不足。以前还以为是windows xp对网络硬盘支持就这样。现在用了virtualbox不存在问题,原来是vmware的linux版本对共享文件价支持不好。所以再支持使用virtualbox.
  virtualbox也有复杂的方面,比如网络设置,种类与vmware差不多,常用的有NAT(客机只与主机进行共享,自动分配IP地址),host interface(直接使用物理网卡,与主机有平等地位,如何连到局域网,由DHCP自动分配等),采用NAT比较简单,只需要设置为NAT方式就可以了,host interface比较麻烦,需要先创建虚拟网卡,再创建桥,再把物理网卡及虚拟网卡加入到桥中,在设置桥的IP或自动得IP,设置好了之后,在吧vbox网络设置中的设备为此桥就可了,下面就只网络上有的一个脚本,运行脚本就可以完成这些工作:
先安装两个工具:
sudo apt-get install uml-utilities bridge-utils
!/bin/sh
# vim:set ft=sh:
## 2007-09 windwiny  vboxbridgedrun.sh
## 使用前自行修改  id,ip,gw,eth?,br?,tap?  等相关参数,
# VirtualBox Bridging VirtualBox 实现桥接模式
## 参考 http://www.oceanboo.cn/read.php?55
#  Ubuntu 里安装软件包
## sudo apt-get install uml-utilities bridge-utils
## ---------------------------------------------------------------------
if [ "$1" = "" ]; then
    echo -e  "$RED\n  `basename "$0"` {start|stop}  $WHTE\n"
    exit 1
fi
if [ `id -u` -ne 0 ]; then
    echo -e  "$RED\n  Must be root  $WHTE\n"
    exit 1
fi
if [ "$1" = "start" ] ; then
        # Create a tap device with permission for the user running vbox
        # 建立一个使用者(user)有权限的设备tap0,-u 参数为自己用户名 或 id
        tunctl -t tap0 -u wangyl # 不能用 `id -u`,因为使用sudo 执行时id为0
        chmod 0666 /dev/net/tun
        # Bring up ethX and tapX in promiscuous mode
        # 将ethx和tapx网卡界面设为混杂模式(Promiscuous)
        ifconfig eth0 0.0.0.0 promisc
        ifconfig tap0 0.0.0.0 promisc
        # Create a new bridge and add the interfaces to the bridge.
        # 建立新的桥接界面(bridge),並把 eth0, tap0加入bridge
        brctl addbr br0
        brctl addif br0 eth0
        brctl addif br0 tap0
        # 下面是两种获取IP的方式,可以自由选择,把不需要的注释掉就好了。
        # 将bridge设成静态IP。XXX都分别对应IP、子网掩码、网关。
        #ifconfig br0 192.168.1.243 netmask 255.255.255.0 up
        #route add default gw 192.168.1.1
        # 将bridge设成动态DHCP分配IP。
        dhclient br0
fi
if [ "$1" = "stop" ] ; then
        ## 刪除 tap0
        tunctl -d tap0
        ##
        ## 刪除 br0
        ifconfig br0 down
        brctl delbr br0
        ##
        ## 将tap0, eth0 移出bridge(br0)
        brctl delif br0 tap0
        brctl delif br0 eth0
        ## 自定义恢复IP地址,默认网关
        #ifconfig eth0 192.168.1.243 netmask 255.255.255.0 up
        #route add default gw 192.168.1.1
        dhclient eth0
fi


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/61789/showart_1360043.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP