Chinaunix首页 | 论坛 | 博客
  • 博客访问: 101104
  • 博文数量: 20
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 240
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-21 11:18
文章分类

全部博文(20)

文章存档

2011年(1)

2009年(3)

2008年(16)

我的朋友

分类: LINUX

2008-11-04 23:25:21

   我分别用了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

在使用中发现一个问题,当ubuntu安装防火墙ufw时,客机XP通过DHCP不能自动分配IP,需关闭ufw.

!/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

阅读(2325) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~