Tuesday, December 2, 2008

Model Lorries Not Painted

VirtualBox. Configure the Linux network.

When installing a VirtualBox virtual machine, the network card is configured in NAT mode, which has not advanced network and, therefore, the performance of the network interface are very limited. In this mode, VirtualBox uses its own router and DHCP , allowing out to the internet from the virtual machine, but preventing, among other things, to communicate with the host computer or, if we have two virtual machines on the same host team, communicate them. To know the limitations we have with this configuration, please consult the help of VirtualBox: Virtual networking -> Networking Address Translation -> NAT Limitations .

This article will configure the network card of the virtual machine so you do not have these limitations and, for example, can connect to the host computer and connection of two or more virtual machines created in the same host computer.

Proper setup is to create a bridge (bridge) to join the network interfaces the host computer and virtual machine or machines. Let it (remember that the host team has installed a Linux distribution, in my case, Ubuntu Linux 8.04).

All the operations we carry out from a terminal. When administrative tasks we will run the command sudo su and write our password to avoid typing sudo before every command.

The initial configuration of the computer's network card can host consult the file / etc / network / interfaces :

elnuevo root @: / home / coralie # cat / etc / network / interfaces

car as

inet loopback iface what

auto eth0

Iface eth0 inet dhcp


lines relating to the interface eth0 may not be included in this file if you are using roaming.

The command ifconfig will display information on network cards:

elnuevo root @: / home / coralie # ifconfig

eth0 Link encap: Ethernet direcciónHW 00:1 d: 72:07: df: f0

inet addr: 192.168.1.33 Broadcast: 192.168.1.255 Mask: 255.255.255.0

address inet6: fe80:: 21d: 72FF: fe07: dff0/64 Scope: Link

UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1

RX packets: 9 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 40 errors: 0 dropped: 0 overruns: 0 carrier: 0

collisions: 0 txqueuelen: 1000

RX bytes: 1254 (1.2 KB) TX bytes: 6028 (5.8 KB)

Interruption: 16


lo Link encap: Local Loopback

inet addr: 127.0.0.1 Mask: 255.0.0.0

address inet6:: 1 / 128 Scope: Host

UP LOOPBACK RUNNING MTU: 16436 Metric: 1

RX packets: 1252 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 1252 errors: 0 dropped: 0 overruns: 0 carrier: 0

collisions: 0 txqueuelen: 0

RX bytes: 62600 (61.1 KB) TX bytes: 62600 (61.1 KB)


To create and use the bridge must download and install the package bridge-utils :

elnuevo root @: / home / coralie # apt-get install bridge -utils

This software installs the necessary utilities to manage the bridge . If we run the order brctl show some of these utilities:

elnuevo root @: / home / coralie # brctl

The next action to take is to create the bridge :

elnuevo root @: / home / coralie br0 # brctl addbr


Then, create a virtual interface to be used from the virtual machine (this action is performed with the order VBoxAddIF VirtualBox provides, available assistance VirtualBox For more information about these commands):

root @ elnuevo: / home / coralie # VBoxAddIF vbox0 coralie br0

VirtualBox host networking interface creation utility, version 1.6. 0

(C) 2005-2007 Sun Microsystems, Inc.

All rights reserved.


Creating the permanent host networking interface "vbox0" for coralie user.


VBoxAddIF Order creates a virtual interface vbox0 be used by the virtual machine, assign permissions to the user coralie to use the interface (this means that this interface can not use another user) and refers to the bridge br0 created previously.

If we use another virtual machine on the same host computer, create another virtual interface for this new machine, since each virtual machine should have its own virtual interface. In the following command creates the virtual interface vbox1 to be used by the user coralie and added to the br0 bridge created above:

elnuevo root @: / home / coralie # VBoxAddIF vbox1 coralie br0

VirtualBox host networking interface creation utility, version 1.6.0

(C) 2005-2007 Sun Microsystems, Inc.

All rights reserved.


Creating the permanent host networking interface "vbox1" for coralie user.


can see bridge configuration with two interfaces virtual have been added by running the following command:

elnuevo root @: / home / coralie # brctl show

bridge name bridge id STP enabled interfaces

br0 8000.00ff09719902 vbox0 not

vbox1


The next action is edit the / etc / network / interfaces for the bridge configuration and network cards real and virtual take effect when you turn on the system or restart networking service . The contents of this file is as follows:

elnuevo root @: / home / coralie # gedit / etc / network / interfaces

car as

the inet loopback iface


Auto eth0

iface eth0 inet dhcp


auto br0

iface br0 inet dhcp

bridge_ports eth0 vbox0 vbox1


The block on the bridge br0 get the IP address for br0 DHCP service and indicates that all information entering or leaving by interfaces eth0, and vbox0 vbox1 be addressed to the bridge .

For everything to work is that lift bridge and restart the networking :

elnuevo root @: / home / coralie # ifconfig br0 up


root @ elnuevo: / home / coralie # / etc / init.d / networking restart


With this configuration everything should work fine, but it is not. The problem is that both the real network card as virtual function intermittently: sometimes yes and sometimes no. The command ifconfig see the configuration we have done:

root @ elnuevo: / home / coralie # ifconfig

br0 Link encap: Ethernet direcciónHW 00: ff: 09:71:99:02

inet addr: 192.168.1.33 Broadcast: 192.168.1.255 Mask: 255.255.255.0

address inet6: fe80:: 2ff: 9ff: fe71: 9902/64 Scope: Link

UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:25 errors:0 dropped:0 overruns:0 carrier:0

colisiones:0 txqueuelen:0

RX bytes:0 (0.0 B) TX bytes:5534 (5.4 KB)



eth0 Link encap:Ethernet direcciónHW 00:1d:72:07:df:f0

inet dirección:192.168.1.33 Difusión:192.168.1.255 Máscara:255.255.255.0 address

inet6: fe80:: 21d: 72FF: fe07: dff0/64 Scope: Link

UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1

RX packets: 15 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 43 errors: 0 dropped: 0 overruns: 0 carrier: 0

collisions: 0 txqueuelen: 1000

RX bytes: 1826 (1.7 KB) TX bytes: 6379 (6.2 KB)

Interruption: 16

lo Link encap: Local Loopback

inet addr: 127.0.0.1 Mask: 255.0.0.0

address inet6:: 1 / 128 Scope: Host

UP LOOPBACK RUNNING MTU: 16436 Metric: 1

RX packets: 1270 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 1270 errors: 0 dropped: 0 overruns: 0 carrier: 0

collisions: 0 txqueuelen: 0

RX bytes: 63500 (62.0 KB) TX bytes: 63500 (62.0 KB)


vbox0 Link encap: Ethernet direcciónHW 00: ff: 09:71:99:02

address inet6: fe80:: 2ff: 9ff: fe71: 9902/64 Scope: Link

UP BROADCAST RUNNING MULTICAST MTU : 1500 Metric: 1

RX packets: 0 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 0 errors: 0 dropped: 25 overruns: 0 carrier: 0

collisions: 0 txqueuelen: 500

RX bytes: 0 (0.0 B) TX bytes: 0 (0.0 B)


vbox1 Link encap: Ethernet direcciónHW 00: ff: ca: ec: c2: 8c

address inet6: fe80:: 2ff: caff: FEEC: c28c/64 Scope: Link

UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1

RX packets: 0 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 0 errors: 0 dropped: 25 overruns: 0 carrier : 0

collisions: 0 txqueuelen: 500

RX bytes: 0 (0.0 B) TX bytes: 0 (0.0 B)


After trying various configurations, I have come to conclusion that the problem arises because the real network card (eth0 ) and bridge (br0 ) share the same IP address (you can see them in the previous output of the command ifconfig ).

The solution I've found is to build the interface eth0 without assigning any IP address and only bridge br0 obtain the IP address. New content file / etc / network / interfaces would be:

root @ elnuevo: / home / coralie # gedit / etc / network / interfaces

car as

inet loopback iface what


auto eth0

iface eth0 inet manual


auto br0

iface br0 inet dhcp

eth0 bridge_ports vbox0 vbox1


The only change I made in this file is changing the line iface eth0 inet dhcp the line iface eth0 inet manual , thereby making interface eth0 adjournment but is not given any direction IP. These settings have been experimenting with two virtual machines (with dual boot Windows and Linux both) over the host team and has worked steadily for several days.

For this configuration to take effect, restart the networking service :

elnuevo root @: / home / coralie # / etc / init.d / networking restart


The command ifconfig see that all interfaces are raised but the interface eth0 has no IP address:

elnuevo root @: / home / coralie # ifconfig

br0 Link encap: Ethernet direcciónHW 00:1 d: 72:07: df: f0

inet addr : 192.168.1.33 Broadcast: 192.168.1.255 Mask: 255.255.255.0

address inet6: fe80:: 21d: 72FF: fe07: dff0/64 Scope: Link

UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1

RX packets:8 errors:0 dropped:0 overruns:0 frame:0

TX packets:27 errors:0 dropped:0 overruns:0 carrier:0

colisiones:0 txqueuelen:0

RX bytes:1042 (1.0 KB) TX bytes:4565 (4.4 KB)



eth0 Link encap:Ethernet direcciónHW 00:1d:72:07:df:f0

dirección inet6: fe80::21d:72ff:fe07:dff0/64 Alcance:Vínculo

UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1

RX packets: 8 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 27 errors: 0 dropped: 0 overruns : 0 carrier: 0

collisions: 0 txqueuelen: 1000

RX bytes: 1186 (1.1 KB) TX bytes: 4697 (4.5 KB)

Interruption: 16


lo Link encap: Local Loopback

inet addr: 127.0.0.1 Mask: 255.0.0.0

address inet6:: 1 / 128 Scope: Host

UP LOOPBACK RUNNING MTU: 16436 Metric: 1

RX packets: 1288 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 1288 errors: 0 dropped: 0 overruns: 0 carrier: 0

collisions: 0 txqueuelen: 0

RX bytes: 64400 (62.8 KB) TX bytes: 64400 (62.8 KB)


vbox0 Link encap: Ethernet direcciónHW 00: ff: 09:71:99:02

address inet6: fe80 :: 2ff: 9ff: fe71: 9902/64 Scope: Link

UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1

RX packets: 0 errors: 0 dropped: 0 overruns: 0 frame : 0

TX packets: 0 errors: 0 dropped: 55 overruns: 0 carrier: 0

collisions: 0 txqueuelen: 500

RX bytes: 0 (0.0 B) TX bytes: 0 (0.0 B)


vbox1 Link encap: Ethernet direcciónHW 00: ff: ca: ec: c2: 8c

address inet6: fe80:: 2ff: caff: FEEC: c28c/64 Scope: Link

UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1

RX packets: 0 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 0 errors: 0 dropped: 33 overruns: 0 carrier: 0

collisions: 0 txqueuelen: 500

RX bytes: 0 (0.0 B) TX bytes: 0 (0.0 B)


If we see the bridge configuration, we get the following output:

elnuevo root @: / home / coralie # brctl show

bridge name bridge id STP enabled interfaces

8000.001d7207dff0 br0 eth0 no

vbox0

vbox1


This output indicates that interfaces eth0, vbox0 vbox1 and are using the bridge Br0 .

Then, assign permissions to users on the directory / dev / net / tun using the system for managing virtual interfaces.

elnuevo root @: / home / coralie # chmod 0666 / dev / net / tun


Finally, you must specify the settings the virtual machine network (from VirtualBox) to be the configuration from the host interface and virtual interface has been created. This action is displayed in the window in Figure 1.

Figure 1

In this window you selected Anfirtión Interface in paragraph Connect and included vbox0 in paragraph Interface name. For the second virtual machine should include vbox1 in paragraph Interface Name and keep the other parameters in Figure 1.

If only going to itself uses a virtual machine on the host computer would have to omit all the settings made for the virtual interface vbox1 .

Remember that the user who will run the virtual machines must be a member of vboxusers .

One final note. If we use virtual machines with other users, create virtual interfaces for these users. Keep in mind that the permission to use the virtual interface is assigned when it is created, using the command VBoxAddIF vbox0 coralie br0. For example, if the user pepe use a virtual machine could not use virtual interfaces created for another user, and would have to use your own. To do this, run the command should VBoxAddIF vbox2 br0 pepe. In addition, the network configuration of your virtual machine (Figure 1), should be included vbox2 in paragraph Interface name. Do not forget edit the file / etc / network / interfaces and add the interface vbox2 in block bridge interface br0 , as follows: eth0 bridge_ports vbox0 vbox1 vbox2.

How could it be otherwise, Sun Microsystems, as of version 2.1.2 of VirtualBox, this configuration has been simplified network. In this article I posted the new method.

0 comments:

Post a Comment