LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1192|回复: 1

我想让vitualbox桥接,以便获得本地局域网的ip地址?请教

[复制链接]
发表于 2007-5-28 00:01:16 | 显示全部楼层 |阅读模式
装了virtualbox,虚拟机网络是nat的,虽然可以上网,但是ip不是本地局域网的ip
于是想到了vmware的bridge桥接方法,网上搜了一下,得到这样一个教程
http://www.happyassassin.net/2007/02/06/vmware-to-virtualbox/
http://ubuntuforums.org/showthread.php?p=2062234#post2062234

虽然不是suse系统但是我想差不多吧于是照做了,用root执行了:
tunctl -t tap0 -u user
chmod 666 /dev/net/tun
brctl addbr br0
ifconfig eth0 0.0.0.0 promisc
brctl addif br0 eth0
dhclient br0
brctl addif br0 tap0
ifconfig tap0 192.168.1.50 up(where 192.168.1.50 is an arbitrary unused IP in the same subnet as your local network)
echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp
route add -host 192.168.1.5 dev tap0 (where 192.168.1.5 is the IP address of the host machine)
arp -Ds 192.168.1.5 eth0 pub (where 192.168.1.5 is the IP address of the host machine)
然后host机ping192.168.1.50可以通,但是虚拟机使用tap0仍然不能dhcp获取到本地局域网ip不能上网
于是我重启了一下,ifconfig发现没有tap0这个interface了
不知道怎么办。。。请教一下
发表于 2007-5-28 00:16:22 | 显示全部楼层
http://www.linuxsir.cn/bbs/showthread.php?t=295232
上面這篇先看看。
如果不想用我的 script,大致的 steps:
    * initial
        # groupadd vbousers
        # gpasswd -a user vboxusers #OR: groupmod -A user vboxusers
    * set up after every reboot
        # chgrp vboxuses /dev/net/tun
        # chmod 0660 /dev/net/tun
        # tunctl -t tap0 -u user
        # brctl addbr br0
        # dhclient -r eth0
        # ifdown eth0
        # ifconfig eth0 0.0.0.0 promisc
        # ifconfig tap0 0.0.0.0 promisc
        # brctl addif br0 eth0
        # brctl addif br0 tap0
        # dhclient br0          # OR: run ifconfig & route manually
    * set down
        # dhclient -r br0
        # brctl delif br0 eth0
        # brctl delif br0 tap0
        # ifconfig tap0 down
        # ifconfig br0 down
        # brctl delbr br0
        # dhclient eth0         # OR: run ifconfig & route manually
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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