環境:OpenSuSE 10.3 搭配 VirtualBox2.2 (主機是 HP Compaq dc7600)
主題:VirtualBox bridge network setting on one NIC (Hewlett-Packard Company NetXtreme BCM5752 Gigabit Ethernet PCI Express)
目的:只有一張網路卡,要達成主客兩端網路互通!在同一網段內。
+=========================================+
Host OS : OpenSuSE 10.3
user id : bullock
Host IP : 10.1.131.201/22 <- eth0 10.1.131.201/255.255.252.0
GateWay : 10.1.131.0
DNS :10.1.131.0, 168.95.1.1
Guest OS: OpenSuSE 10.3 or something else like Windows XP...
Guest IP: 10.1.131.202/22 <- eth0 10.1.131.201/255.255.252.0
Gateway and DNS : 比照 Host
(若有DHCP Server配合更佳!)
基本步驟:
1. Turn down interface 'eth0'.
# /sbin/ifconfig eth0 down
2. Set IP address of 'eth0' to 0.0.0.0 and with 'promisc' mode.
# /sbin/ifconfig eth0 0.0.0.0 promisc
3. Create bridge interface 'br0' and set IP address and netmask of 'br0'
to the value of IP address and netmask 'eth0' before we set it to 0.0.0.0.
3.1
再手動創造出bridge用的虚擬網路,並把原IP綁上!
# /sbin/brctl addbr br0
# /sbin/ifconfig br0 10.1.131.201 netmask 255.255.252.0
# /sbin/route add default gw 10.1.131.0
3.2
若要每次開機都自動生bridge相關的NIC
目前不建議作到這層次,因為開機就套用bridge network,並不必然。
除非虚擬機器也是正式提供服務的主機!
# vi /etc/sysconfig/network/ifcfg-eth0
[修改範例]
BOOTPROTO='static'
STARTMODE='ifplugd'
IFPLUGD_PRIORITY='1'
#IPADDR='10.1.131.201/22' <-註解掉不用
NAME='Hewlett-Packard Company NetXtreme BCM5752 Gigabit Ethernet PCI Express'
USERCONTROL='no'
LINK_OPTIONS='promisc on'
# vi /etc/sysconfig/network/ifcfg-br0
[修改範例]
BOOTPROTO='static'
STARTMODE='auto'
IPADDR='10.1.131.201/22'
NETMASK='255.255.252.0' #<-可略
NAME='bridge for vbox'
BRIDGE='yes'
BRIDGE_PORTS='eth0 tap0'
BRIDGE_FORWARDDELAY='0'
4. Add 'eth0' to 'br0'.
# /sbin/brctl addif br0 eth0
5. Create virtual network card 'tap0' with VBoxTunctl and add 'tap0' to bridge 'br0'.
# /usr/bin/VBoxTunctl -t tap0 -u bullock
# /sbin/brctl addif br0 tap0
6. Do not forget to set 'tap0' to 'promisc' mode too.
# /sbin/ifconfig tap0 promisc
7. Bring all interface up.
# /sbin/ifconfig tap0 up
# /sbin/ifconfig eth0 up
# /sbin/ifconfig br0 up
PS/若是要再有第二個以上的虚擬機器使用,而要再增加tap1,tap2 ……
請在 步驟5. 6. 7. 針酌加上tap1,tap2的啓用指令
[補遺]
有關防火牆問題排除!
在上述配置bridge network時,會先把防火牆關閉。
而在配置完之後,若是再啓用防火牆,會發現到Guset OS的網路被斷掉!
要如何在Host 也啓用防火牆的狀態下,也保持bridge network的正常運作呢?
以下擷取一小段官網文件,可以解決此一問題。
+---------------------------------------------------------------------------------+
OpenSuSE Firewall Issues
OpenSuSE firewall can interfere with bridging. To solve this, edit:
/etc/sysconfig/SuSEfirewall2
by adding a line to the end (where "br0" if the identifier of the bridge device)
FW_FORWARD_ALWAYS_INOUT_DEV="br0"
+---------------------------------------------------------------------------------+
台股大盤表現
3 天前
2 則留言:
哈哈,你也在用VBOX啊!
我也在用!
http://blog.freebapp.org/2009/05/virtualboxfreebsd.html
是啊!
我比較傾向用LINUX當Host端。
再拿windows當Guset端!
你的例子也不錯,有空參照著來裝一回。
張貼留言