- http://www.virtualbox.org/discussion/1/141
- http://www.virtualbox.org/wiki/Automatic_Bridge_Ubuntu
Me basé Principalmente la primer guía. Cito a continuación su contenido:
"
I have a "typical" production requirement. My linux host needs a static IP address. I also have a linux guest that needs a different IP address in the same subnet on the same ethernet interface.
I managed to get my system working using the instructions in the VirtualBox User Manual, but needed automatic configuration when the host system boots. I found so much confusing information around that I thought it would be useful to document what I did (and why it works). This guide applies to Ubuntu Dapper 6.06 LTS, but will probably apply to later releases and other Debian distributions.
The network interface drivers are loaded early in the boot process. Further configuration takes place under the control of /etc/rcS.d/S40networking, which uses the /etc/network/interfaces control file.
You need to have installed both the uml-utils and bridge-utils packages before you start.
The key concept is that you will create an internal (virtual) ethernet bridge on your host operating system. The only external interface on this bridge will be the real ethernet card on the machine. We will also define a TAP (virtual) interface on the bridge to be used by the guest machine. The host operating system does NOT need to know how this interface will be used.
I assume both the host and the guest machines need to access the external network, each using their own unique IP addresses.
1. Configure the real ethernet interface
You have probably already configured the real ethernet interface during installation of the host linux system. This is no longer required. Edit the /etc/network/interfaces file and change the relevant section (mine is eth0) as follows :
auto eth0
iface eth0 inet manual
This section says the eth0 interface is to be brought up automatically during system boot (and also with ifup -a), but the interface is NOT to be configured further.
2. Define a TAP interface to be used by the guest virtual machine
I decided my production virtual guest should always have its own virtual network adapter which is setup when the host system boots. It is defined by adding a new section to /etc/network/interfaces :
auto tap1
iface tap1 inet manual
tunctl_user brian
The name of this interface MUST match the Host Interface Name of the virtual adapter for the virtual machine.
It is not configured in the host system, because the guest operating system will configure the interface when it boots... either with static values or from a DHCP server.
The TAP interface will be created when the host system boots and it MUST be associated with a valid HOST username that the guest virtual machine will run under. It MUST also be a member of the uml-net group.
The tunctl_user attribute is processed by the /etc/network/if-up.d/uml-utilities script.
3. Define the ethernet bridge
The definitions in /etc/network/interfaces are processed in physical order. This means you MUST define the bridge AFTER the interfaces that will be associated with the bridge. Add a new section to the file something like this:
auto bridge0
iface bridge0 inet static
address 10.1.100.101
netmask 255.255.255.0
broadcast 10.1.100.255
gateway 10.1.100.1
bridge-ports eth0 tap1
bridge-ageing 7200
bridge-fd 0
The first few statements assign a meaningful static IP configuration to the external interface of the bridge. This ensures the bridge knows how to communicate with other hosts on the same local LAN. The gateway statement ensures the bridge can route messages to the rest of the network. (If you don't have a "production" environment, you could use "iface bridge inet dhcp" instead to get the interface automatically configured by a DHCP server.)
The following three bridge-* statements are processed by the script /etc/network/if-pre-up.d/uml-utilities. The external (real) and the TAP interfaces are both added to the bridge. This means the virtual machine will be able to communicate with the external network via the local LAN.
I set bridge-aging (equivalent to "brctl setageing") to 2 hours because only my virtual machines use the bridge and I do not expect them to change very much. I also set the forward delay to zero because I want to be sure the host and VM's get their messages sent quickly soon after they boot.
This bridge configuration will automatically create two IP routes on the host - one for the local LAN subnet and the other for a default route to the local gateway router. Both these routes are via the bridge. With this kind of setup, no explicit routes are required.
4. Testing
The new TAP interface can be brought up with "sudo ifup [-v] tap1" and down again with "sudo ifdown tap1". Verify it is UP without ANY IPv4 configuration using "ifconfig tap1".
The best way to reset the ethernet interface is with "sudo ifdown eth0" and "sudo ifup eth0". However, this might not work properly if your interface has been previously configured for IP. You can also try resetting it with "sudo ifconfig eth0 0.0.0.0 down", but I've not been able to get rid of an unwanted netmask (as others have suggested) by assigning all zeros. If "ifconfig eth0" still shows residual IPv4 configuration, you might need to reboot so the new /etc/network/interfaces becomes active.
You can bring up the bridge manually with "sudo ifup [-v] bridge0". You can verify your configuration with "ifconfig bridge0", "sudo brctl show bridge0" and "netstat -r". You should be able to access your local LAN and the rest of the external network from the host operating system.
Next, boot your virtual machine and use it's operating system tools to configure the virtual network interface. The VM should have access to the external network via the bridge.
Finally, shutdown and reboot the host. Confirm your bridge configuration is still as expected.
5. Other configurations
I haven't tested any other configurations, such as using DHCP for the bridge interface, or wireless 802.11 for the real network interface. However, I hope my procedure makes enough sense for you to adapt it to these other situations.
No hay comentarios:
Publicar un comentario