我的系统是fedora 9
virtualbox版本是1.6
防火墙已关闭
我的配置步骤如下
1》创建网桥br0
brctl addbr br0
2》配置网桥
touch /etc/sysconfig/network-scripts/ifcfg-br0
vi /etc/sysconfig/network-scripts/ifcfg-br0
e.g:
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static #最好是设定静态IP,否则为dhcp,并不要设IPADDR和NETMASK及GATEWAY(我的采用dhcp无法分配ip,不懂)
IPADDR=192.168.19.85
NETMASK=255.255.255.0
ONBOOT=yes
GATEWAY=0.0.0.0 #网关我设置的0.0.0.0,本机直接发送
3》Put your network adapter in promiscuous mode so that it will accept Ethernet frames for MAC addresses other than its own:
ifconfig eth0 0.0.0.0 promisc #ifconfig不改变配置文件,只是用了测试网络,所以这里没搞明白,是不是每次都有执行一次阿,而且开始我没有加promisc,也开启了promisc,不明白,这条命令是干什么呢,为什么是0.0.0.0
4》把eth0加进br0
brctl addif br0 eth0 #或者直接修改脚本文件/etc/sysconfig/network-scripts/ifcfg-eth0,最后加一行BRIDGE=br0
e.g:
DEVICE=eth0 #在Linux下,网桥接口和第一个加入的接口MAC地址保持一致。
TYPE=Ethernet
BOOTPROTO=dhcp
ONBOOT=yes
BRIDGE=br0
5》创建一个新的虚拟的host interface
VboxAddIF vbox0 user br0 #这里我指定user用户能使用此虚拟卡
6》重启网络服务
service network restart
7》在虚拟机的虚拟网卡中设置interface name 为vbox0,开启虚拟机就ok了
此时可以用ifconfig查看网络情况。
[root@localhost ~]# ifconfig
br0 Link encap:Ethernet HWaddr 00:50:8D:71:3A:8B
inet addr:192.168.19.85 Bcast:192.168.19.255 Mask:255.255.255.0
inet6 addr: fe80::250:8dff:fe71:3a8b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:135300 errors:0 dropped:0 overruns:0 frame:0
TX packets:55898 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:54820879 (52.2 MiB) TX bytes:10993191 (10.4 MiB)
eth0 Link encap:Ethernet HWaddr 00:50:8D:71:3A:8B 为什么没显示ip
inet6 addr: fe80::250:8dff:fe71:3a8b/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:3042446 errors:0 dropped:0 overruns:0 frame:0
TX packets:116092 errors:3 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1472099198 (1.3 GiB) TX bytes:40544742 (38.6 MiB)
Interrupt:23 Base address:0xc000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:12807 errors:0 dropped:0 overruns:0 frame:0
TX packets:12807 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:711513 (694.8 KiB) TX bytes:711513 (694.8 KiB)
vbox0 Link encap:Ethernet HWaddr 00:FF:86:81:98:1C
inet6 addr: fe80::2ff:86ff:fe81:981c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:119865 errors:0 dropped:0 overruns:0 frame:0
TX packets:163440 errors:0 dropped:37727 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:72319447 (68.9 MiB) TX bytes:77943649 (74.3 MiB)
4.关于配置中的问题:
1》配置好后eth0就无法激活了,adsl无法联网了,下面方法都用了,还是无法解决。恼火,不过最后按照上面的配置,确实可以像说的那样的加入到局域网了,并且guest操作系统也可以adsl拨号上网了,就是无法linux 联网了。
Remove the IP address configuration from the existing network device (e.g. eth0) with:
ifconfig eth0 0.0.0.0
Warning: You will lose network connectivity on eth0 at this point.
For configurations where the network adapter is configured statically, you need to setup br0 exactly as you would have set up eth0. At this point the host should have network connectivity again.
就是关于eth0静态ip的时候,br0要和eth0能相同的都相同。
2》另外的参考
此时Host应该已经失去了联网能力,不要紧张。对于非DHCP的情况,需要将br0配置的和原来的 eth0一模一样,具体的说,相同IP,并且取代eth0作为默认路由的出口。
sudo ifconfig br0 192.168.19.85 up
sudo route del default
sudo route add default gw 192.168.19.85 dev br0
[root@localhost ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.19.0 0.0.0.0 255.255.255.0 U 0 0 0 br0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br0
0.0.0.0 192.168.19.85 0.0.0.0 UG 0 0 0 br0
以上是我的整个配置过程了,有疑问的地方我用红色标出了,其中最主要的是无法连接adsl上网了,还望高手指点,先行谢过。
(e:e2s
[ 本帖最后由 jilk005 于 2008-10-16 01:22 编辑 ]