Difference between revisions of "VirtualBox"

From Vlsiwiki
Jump to: navigation, search
(END ============)
m (Bridge and tap script)
Line 6: Line 6:
 
Create an .sh script with the following.  Be sure to change the USER and NUMBER_OF_VM switches accordingly.
 
Create an .sh script with the following.  Be sure to change the USER and NUMBER_OF_VM switches accordingly.
  
=================================== BEGIN SCRIPT ===============================================
+
install needed packages
 +
* bridge-utils
 +
* uml-utilities
  
run this script on local host
+
run this script on local host as root
#!/bin/sh
+
# set PATH for the case we are called via sudo or su root
+
  
PATH=/sbin:/usr/bin:/bin:/usr/bin:/usr/sbin/
+
#!/bin/sh
USER=michael_VM
+
# set PATH for the case we are called via sudo or su root
 
+
NUMBER_OF_VM=1
+
PATH=/sbin:/usr/bin:/bin:/usr/bin:/usr/sbin/
# create the bridge
+
USER=michael_VM
brctl addbr br0
+
 
+
NUMBER_OF_VM=1
# create the taps and insert them into the bridge
+
# create the bridge
 
+
brctl addbr br0
NB=1
+
while [ $NB -lt $NUMBER_OF_VM ]
+
# create the taps and insert them into the bridge
do
+
 +
NB=1
 +
while [ $NB -lt $NUMBER_OF_VM ]
 +
do
 
   tunctl -t tap$NB -u $USER
 
   tunctl -t tap$NB -u $USER
 
   ip link set up dev tap$NB
 
   ip link set up dev tap$NB
 
   brctl addif br0 tap$NB
 
   brctl addif br0 tap$NB
 
   let NB=$NB+1
 
   let NB=$NB+1
done
+
done
 
+
# set the IP address and routing
+
# set the IP address and routing
ip link set up dev br0
+
ip link set up dev br0
ip addr add 10.1.1.1/24 dev br0
+
ip addr add 10.1.1.1/24 dev br0
ip route add 10.1.1.0/24 dev br0
+
ip route add 10.1.1.0/24 dev br0
  
 
=================================== END SCRIPT ===============================================
 
=================================== END SCRIPT ===============================================

Revision as of 23:27, 9 June 2010

Set up networking for VirtualBox:

local = host OS that runs VBox VM# = VBox that runs on local host

Create an .sh script with the following. Be sure to change the USER and NUMBER_OF_VM switches accordingly.

install needed packages

  • bridge-utils
  • uml-utilities

run this script on local host as root

#!/bin/sh
# set PATH for the case we are called via sudo or su root

PATH=/sbin:/usr/bin:/bin:/usr/bin:/usr/sbin/
USER=michael_VM

NUMBER_OF_VM=1
# create the bridge
brctl addbr br0

# create the taps and insert them into the bridge

NB=1
while [ $NB -lt $NUMBER_OF_VM ]
do
  tunctl -t tap$NB -u $USER
  ip link set up dev tap$NB
  brctl addif br0 tap$NB
  let NB=$NB+1
done

# set the IP address and routing
ip link set up dev br0
ip addr add 10.1.1.1/24 dev br0
ip route add 10.1.1.0/24 dev br0
============================= END SCRIPT =========================================

Your host requires a bridge for every VBox that you need to run concurrently.


Change the IPADDR to make it UNIQUE

Edit the VMBox's /etc/sysconfig/network-script/ifcfg-eth0 file


============================= START =========================================
  1. Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]

DEVICE=eth0 BOOTPROTO=noe HWADDR=08:00:27:BF:37:7F ONBOOT=yes NETMASCK=255.255.255.0 IPADDR=10.1.1.15 USERCTL=no PEERDNS=yes GATEWAY=10.1.1.15 TYPE=Ethernet IPV6INIT=no

============================= END =========================================

Within Virtual Box GUI, change the networking to a single BRIDGED interface that uses br0.




Note: The above script needs to have the correct amount of TAPS, otherwise some VM's won't have networking.

Note: Make sure to have an /etc/resolv.conf file that ONLY has the line. Bringing eth0 up will take a very long time otherwise.

  search localdomain


Consult this wiki http://www.virtualbox.org/wiki/Advanced_Networking_Linux