Difference between revisions of "VirtualBox"
From Vlsiwiki
Tom Golubev (Talk | contribs) (→END ============) |
m (Adjust math) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | To set up networking for VirtualBox: | |
− | + | install needed packages | |
− | + | * bridge-utils | |
+ | * uml-utilities | ||
− | + | ;local | |
+ | :host OS that runs VBox | ||
+ | ;VM# | ||
+ | :VBox that runs on local host | ||
− | |||
− | + | Create a .sh script with the following. | |
− | #!/bin/sh | + | #!/bin/sh |
− | # set PATH for the case we are called via sudo or su root | + | # set PATH for the case we are called via sudo or su root |
− | + | ||
− | PATH=/sbin:/usr/bin:/bin:/usr/bin:/usr/sbin/ | + | PATH=/sbin:/usr/bin:/bin:/usr/bin:/usr/sbin/ |
− | USER=michael_VM | + | USER=michael_VM |
− | + | ||
− | NUMBER_OF_VM=1 | + | NUMBER_OF_VM=1 |
− | # create the bridge | + | # create the bridge |
− | brctl addbr br0 | + | brctl addbr br0 |
− | + | ||
− | # create the taps and insert them into the bridge | + | # create the taps and insert them into the bridge |
− | + | ||
− | NB=1 | + | NB=1 |
− | while [ $NB -lt $NUMBER_OF_VM ] | + | while [ $NB -lt $(($NUMBER_OF_VM+1)) ] |
− | do | + | 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 | ||
− | + | 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 |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | run this script on local host as root | ||
+ | :Be sure to change the USER and NUMBER_OF_VM switches accordingly. | ||
+ | :USER should be the owner of the taps on the local host | ||
+ | Your host requires only one bridge, but a tap for every VBox that you need to run concurrently. If you install too few taps then some VM's won't have networking. | ||
+ | Change the IPADDR of each VM# to make them unique | ||
+ | :Edit the VMBox's /etc/sysconfig/network-script/ifcfg-eth0 file or whichever file is appropriate for the guest OS | ||
+ | # 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 | ||
− | + | Within Virtual Box GUI, change the networking to a single '''bridged''' interface that uses br0. | |
+ | Note: Make sure to have an /etc/resolv.conf file on the VM guest OS that is empty except for the following line. | ||
+ | search localdomain | ||
+ | Otherwise in the guest OS bringing eth0 up or trying to use ssh will take a very long time. | ||
− | + | For further issues consult this wiki http://www.virtualbox.org/wiki/Advanced_Networking_Linux |
Latest revision as of 00:01, 10 June 2010
To set up networking for VirtualBox:
install needed packages
- bridge-utils
- uml-utilities
- local
- host OS that runs VBox
- VM#
- VBox that runs on local host
Create a .sh script with the following.
#!/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+1)) ] do tunctl -t tap$NB -u $USER ip link set up dev tap$NB brctl addif br0 tap$NB 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
run this script on local host as root
- Be sure to change the USER and NUMBER_OF_VM switches accordingly.
- USER should be the owner of the taps on the local host
Your host requires only one bridge, but a tap for every VBox that you need to run concurrently. If you install too few taps then some VM's won't have networking.
Change the IPADDR of each VM# to make them unique
- Edit the VMBox's /etc/sysconfig/network-script/ifcfg-eth0 file or whichever file is appropriate for the guest OS
# 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
Within Virtual Box GUI, change the networking to a single bridged interface that uses br0.
Note: Make sure to have an /etc/resolv.conf file on the VM guest OS that is empty except for the following line.
search localdomain
Otherwise in the guest OS bringing eth0 up or trying to use ssh will take a very long time.
For further issues consult this wiki http://www.virtualbox.org/wiki/Advanced_Networking_Linux