请教一下VirtualBox网络设置的问题

Kvm、VMware、Virtualbox、Xen、Qemu 等
回复
woooo
帖子: 83
注册时间: 2007-08-11 16:37
来自: HUBEI WUHAN

请教一下VirtualBox网络设置的问题

#1

帖子 woooo » 2007-09-16 14:19

在ubuntu里面安装完VirtualBox后,虚拟出来的WINXP,默认的网络类型是NAT,IP用自动,DNS手工,

就可以上网了,就是不能访问主机IP,

另外Host Interface和Internrl Network该如何配置,

我想要虚拟机能够使用LAN的IP(工作需要),我改怎么设置?

哪位高手发下设置教材.谢谢!!
woooo
帖子: 83
注册时间: 2007-08-11 16:37
来自: HUBEI WUHAN

#2

帖子 woooo » 2007-09-20 14:32

?难道没有人能回答我的问题吗????
头像
windwiny
帖子: 2254
注册时间: 2007-03-13 17:26

#3

帖子 windwiny » 2007-09-20 15:26

代码: 全选

#!/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 n1 # 不能用 `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
fi
实现桥接,Vbox里网络选 Host Interface,虚拟机中的系统 IP地址段 设为与主机 IP 段相同,主机与客户机可互相访问IP
附件
20070920-152355.jpg
xwmlinux
帖子: 72
注册时间: 2008-09-17 19:54

Re: 请教一下VirtualBox网络设置的问题

#4

帖子 xwmlinux » 2008-10-06 21:08

桥接两个网卡(物理网卡和虚拟网卡),桥的IP就是你宿主机IP。虚拟机里的网络设置只要网段跟宿主机一样就行了。
桥的IP设置你当它是一个网卡一样来设置就行了。
虚拟机的网关,DNS跟宿主机一样。

最后提醒一下你。VBOX,选择了虚拟网卡连接后,确认“接入网线”已经选上。

以上无论是在WIN里虚拟LINUX,还是在LINUX里虚拟WIN,一样原理。

在WIN里桥接只要选中两个网卡,右键桥接就行了。
在LINUX下桥接稍麻烦。参考楼上脚本命令吧。
Horontu
帖子: 120
注册时间: 2006-10-21 21:04

Re: 请教一下VirtualBox网络设置的问题

#5

帖子 Horontu » 2008-11-21 16:32

我的桥接有问题……

桥接后宿主机就断网了……,而且提示“网线未插好”,但网线明明是接在网卡上的,只要删除了桥接就又OK了。而且桥接后,宿主机无法获取与虚拟机同段的IP地址,就是说即便这样,依然无法实现宿主机与虚拟机的互访通讯,请问这是什么问题呢?
忘了说,我是在windows xp系统下,虚拟ubuntu和windows 都是这个情况……

请大家指点下,谢谢!!
回复